PickleJar is a python module that allows you to work with multiple pickles inside a single file (I call it a “jar”)!
- class picklejar.Jar(filepath: str)[source]¶
A file containing multiple pickle objects
- Parameters:
filepath (str, required) – Path to the file
- Returns:
None
- Return type:
None
- dump(items: Any, new_jar: bool = False, collapse: bool = False) bool[source]¶
Write a Pickle to the file/jar.
- Parameters:
items (Any) – Item or list of items to pickle
new_jar (bool, optional) – Start a new jar (Default: False)
collapse – If items is a list write list as single pickle
- Returns:
True on file write
- Return type:
bool
- load(always_list: bool = False) Any[source]¶
Loads all the pickles out of the file/jar
- Parameters:
always_list (bool, optional) – Ensure that Jars with single pickle return as a list (Default: False)
- Returns:
List of de-pickled objects or de-pickled object if always_list is False and pickled object is not list
- Return type:
Any
- Raises:
IOError
Compatibility¶
As of version 3.0.0, Picklejar is compatible with the latest supported versions of Python3!
If you are looking to use picklejar with Python2.7 please use version 2.1.2.