dantro.data_loaders.load_pkl module¶
-
class
dantro.data_loaders.load_pkl.PickleLoaderMixin[source]¶ Bases:
objectSupplies functionality to load pickled python objects
-
_PICKLE_LOAD_FUNC()¶ Read and return an object from the pickle data stored in a file.
This is equivalent to
Unpickler(file).load(), but may be more efficient.The protocol version of the pickle is detected automatically, so no protocol argument is needed. Bytes past the pickled object’s representation are ignored.
The argument file must have two methods, a read() method that takes an integer argument, and a readline() method that requires no arguments. Both methods should return bytes. Thus file can be a binary file object opened for reading, an io.BytesIO object, or any other custom object that meets this interface.
Optional keyword arguments are fix_imports, encoding and errors, which are used to control compatibility support for pickle stream generated by Python 2. If fix_imports is True, pickle will try to map the old Python 2 names to the new names used in Python 3. The encoding and errors tell pickle how to decode 8-bit string instances pickled by Python 2; these default to ‘ASCII’ and ‘strict’, respectively. The encoding can be ‘bytes’ to read these 8-bit string instances as bytes objects.
-
_load_pickle(*args, **kwargs)¶ Load a pickled object.
This uses the load function defined under the _PICKLE_LOAD_FUNC class variable, which defaults to the pickle.load function.
- Parameters
filepath (str) – Where the pickle-dumped file is located
TargetCls (type) – The class constructor
**pkl_kwargs – Passed on to the load function
- Returns
The unpickled file, stored in a dantro container
- Return type
-
_load_pkl(*args, **kwargs)¶ Load a pickled object.
This uses the load function defined under the _PICKLE_LOAD_FUNC class variable, which defaults to the pickle.load function.
- Parameters
filepath (str) – Where the pickle-dumped file is located
TargetCls (type) – The class constructor
**pkl_kwargs – Passed on to the load function
- Returns
The unpickled file, stored in a dantro container
- Return type
-