logml.serialization

Functions

dump_json(path, obj[, cls])

Dumps a given object into JSON file.

dump_pickle(path, obj)

Dumps a given object into pickle file.

dump_yaml(path, obj)

Dumps a given object into pickle file.

getsize(obj)

Calculate total size of object & members.

load_json(path)

Loads and returns a json object from a given path.

load_pickle(path)

Loads and returns a pickle object from a given path.

load_yaml(path)

Loads and returns an object from a given yaml file.

Classes

LogmlJSONEncoder(*[, skipkeys, ...])

Logml-specific Json Encoder

class logml.serialization.LogmlJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.encoder.JSONEncoder

Logml-specific Json Encoder

default(o)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
logml.serialization.load_json(path: str)

Loads and returns a json object from a given path.

logml.serialization.dump_json(path: str, obj, cls=<class 'logml.serialization.LogmlJSONEncoder'>, **kw)

Dumps a given object into JSON file.

logml.serialization.load_pickle(path: Union[str, pathlib.Path])

Loads and returns a pickle object from a given path.

logml.serialization.dump_pickle(path: str, obj)

Dumps a given object into pickle file.

logml.serialization.load_yaml(path: str)

Loads and returns an object from a given yaml file.

logml.serialization.dump_yaml(path: str, obj)

Dumps a given object into pickle file.

logml.serialization.getsize(obj) int

Calculate total size of object & members. See https://stackoverflow.com/questions/449560/how-do-i-determine-the-size-of-an-object-in-python