picklers
¶
Has two main parts:
The picklersIO classes (all
BasePicklerIO
subclasses)The picklerIO registry.
The picklerIO classes must provide a minimum signature defined in the the common base class: BasePicklerIO
, and are in charge of writing or reading serialized python objects into and from file-like objects.
|
Get the PicklerIO class registered with a given pickler name. |
|
Register a pickler handler. |
Get a list of known pickle serialization methods. |
|
Get the list of registered PicklerIO classes. |
|
PicklerIO abstract base class. |
|
A PicklerIO class that wraps standard |
|
A PicklerIO class that combines |
|
A PicklerIO class that wraps standard |
|
A PicklerIO class that wraps |
|
A PicklerIO class that wraps |
Registry¶
- compress_pickle.picklers.registry.get_known_picklers() List[str] [source]¶
Get a list of known pickle serialization methods.
- Returns
List of known pickler serialization methods.
- Return type
List[str]
- compress_pickle.picklers.registry.get_pickler(name: str) Type[compress_pickle.picklers.base.BasePicklerIO] [source]¶
Get the PicklerIO class registered with a given pickler name.
- Parameters
name (str) – The pickler name.
- Raises
ValueError – If the supplied
name
has not been registered.- Returns
The PicklerIO class associated to the pickler
name
.- Return type
- compress_pickle.picklers.registry.list_registered_picklers() List[Type[compress_pickle.picklers.base.BasePicklerIO]] [source]¶
Get the list of registered PicklerIO classes.
- Returns
The list of registered pickler classes.
- Return type
List[BasePicklerIO]
- compress_pickle.picklers.registry.register_pickler(name: str, pickler: Type[compress_pickle.picklers.base.BasePicklerIO])[source]¶
Register a pickler handler.
- Parameters
name (str) – The pickler name that will be registered.
pickler (Type[BasePicklerIO]) – The PicklerIO class. This should be a
BasePicklerIO
subclass.
- Raises
ValueError – If the supplied
name
is already contained in the registry.TypeError – If the supplied pickler is not a
BasePicklerIO
subclass.
PicklerIO¶
- class compress_pickle.picklers.base.BasePicklerIO[source]¶
PicklerIO abstract base class.
This class is in charge of writing and reading serialized python objects from a file-like binary stream.
- abstract dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- Parameters
obj (Any) – The python object that must be serialized and written.
stream (IO[bytes]) – The binary stream (file-like object) where the serialized object must be written to.
kwargs – Any extra keyword arguments that are needed in the concrete implementation of
dump
.
- abstract load(stream: IO[bytes], **kwargs)[source]¶
Load a serialized binary representation of an object from a stream.
- Parameters
stream (IO[bytes]) – The binary stream (file-like object) from where the serialized object must be loaded.
kwargs – Any extra keyword arguments that are needed in the concrete implementation of
load
.
- Returns
obj – The python object that was loaded.
- Return type
Any
- class compress_pickle.picklers.pickle.BuiltinPicklerIO[source]¶
A PicklerIO class that wraps standard
pickle.dump()
andpickle.load()
.- dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- Parameters
obj (Any) – The python object that must be serialized and written.
stream (IO[bytes]) – The binary stream (file-like object) where the serialized object must be written to.
kwargs – Any extra keyword arguments to pass to
pickle.dump()
.
- load(stream: IO[bytes], **kwargs)[source]¶
Load a serialized binary representation of an object from a stream.
- Parameters
stream (IO[bytes]) – The binary stream (file-like object) from where the serialized object must be loaded.
kwargs – Any extra keyword arguments to pass to
pickle.load()
.
- Returns
obj – The python object that was loaded.
- Return type
Any
- class compress_pickle.picklers.optimized_pickle.OptimizedPicklerIO[source]¶
A PicklerIO class that combines
pickletools.optimize()
and standardpickle.dump()
.- dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- Parameters
obj (Any) – The python object that must be serialized and written.
stream (IO[bytes]) – The binary stream (file-like object) where the serialized object must be written to.
kwargs – Any extra keyword arguments to pass to
pickle.dump()
.
- class compress_pickle.picklers.marshal.MarshalPicklerIO[source]¶
A PicklerIO class that wraps standard
marshal.dump()
andmarshal.load()
.- dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- Parameters
obj (Any) – The python object that must be serialized and written.
stream (IO[bytes]) – The binary stream (file-like object) where the serialized object must be written to.
kwargs – Any extra keyword arguments to pass to
marshal.dump()
.
- load(stream: IO[bytes], **kwargs)[source]¶
Load a serialized binary representation of an object from a stream.
- Parameters
stream (IO[bytes]) – The binary stream (file-like object) from where the serialized object must be loaded.
kwargs – Any extra keyword arguments to pass to
marshal.load()
.
- Returns
obj – The python object that was loaded.
- Return type
Any
- class compress_pickle.picklers.dill.DillPicklerIO[source]¶
A PicklerIO class that wraps
dill.dump
anddill.load
.- dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- class compress_pickle.picklers.cloudpickle.CloudPicklerIO[source]¶
A PicklerIO class that wraps
cloudpickle.dump
andcloudpickle.load
.- dump(obj: Any, stream: IO[bytes], **kwargs)[source]¶
Write a serialized binary representation of an object to a stream.
- Parameters
obj (Any) – The python object that must be serialized and written.
stream (IO[bytes]) – The binary stream (file-like object) where the serialized object must be written to.
kwargs – Any extra keyword arguments to pass to
cloudpickle.dump
.
- load(stream: IO[bytes], **kwargs)[source]¶
Load a serialized binary representation of an object from a stream.
- Parameters
stream (IO[bytes]) – The binary stream (file-like object) from where the serialized object must be loaded.
kwargs – Any extra keyword arguments to pass to
cloudpickle.load
.
- Returns
obj – The python object that was loaded.
- Return type
Any