dill
dill extends Python's pickle module for serializing and deserializing Python objects, supporting a wide range of built-in types. The current version is 0.4.1, released on January 19, 2026, with active development and regular updates.
Warnings
- breaking Function 'dump_session()' was renamed to 'dump_module()' in version 0.3.6. Parameters 'main' and 'byref' were renamed to 'module' and 'refimported', respectively.
- deprecated The 'dill.settings['byref']' and 'dill.settings['recurse']' settings do not apply to the 'dump_module()' function.
Install
-
pip install dill
Imports
- dill
import dill
Quickstart
import dill
# Serialize an object
obj = {'key': 'value'}
with open('obj.pkl', 'wb') as f:
dill.dump(obj, f)
# Deserialize the object
with open('obj.pkl', 'rb') as f:
loaded_obj = dill.load(f)
print(loaded_obj)