Registry / serialization / dill
library0.4.1pypypi✓ verified 26d ago

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.

pip install dill
INSTALL
IMPORT
SIG · DILL
D
dill
serializationpythonv0.4.1
Install
1.7s avg
Import
164ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.168s · 18.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.160s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dill
import dill
dill is imported directly as 'dill'

A basic example demonstrating how to serialize and deserialize an object using dill.

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)
Debug
Known issues
breakingFunction 'dump_session()' was renamed to 'dump_module()' in version 0.3.6. Parameters 'main' and 'byref' were renamed to 'module' and 'refimported', respectively.
fix
Update function calls to 'dump_module()' with the new parameter names.
affects: 0.3.6
deprecatedThe 'dill.settings['byref']' and 'dill.settings['recurse']' settings do not apply to the 'dump_module()' function.
fix
Avoid using these settings with 'dump_module()'.
affects: 0.3.6
Errors
Common errors & fixes
AttributeError: module 'dill._dill' has no attribute 'log'
This error typically occurs due to an incompatibility or version mismatch between the installed `dill` library and another dependent package (e.g., `datasets`, `nlp`) that expects a specific internal attribute of `dill` which has been removed or renamed in a newer version.
fix
Downgrade `dill` to a version compatible with the dependent library. For example, `pip install dill==0.3.5.1` or `pip install dill<0.3.6` if the issue is with `log` or `PY3` (check the dependent library's requirements).
ModuleNotFoundError: No module named 'dill'
The `dill` library is not installed in the Python environment where the code is being executed, or there is a naming conflict where a local script is named `dill.py`.
fix
Install the `dill` package using pip: `pip install dill`. If a local script is named `dill.py`, rename it to avoid conflicting with the library import.
_pickle.PicklingError: Can't pickle <class '__main__.MyClass'>: it's not the same object as __main__.MyClass
While `dill` enhances Python's `pickle`, complex objects, especially dynamically created classes or objects defined directly in the `__main__` module, can still sometimes cause `PicklingError` if their exact context or definition isn't correctly preserved or recreated during deserialization, particularly across different environments or when `dill` is used with default `pickle`-like behavior for certain types.
fix
Ensure you are explicitly importing and using `dill` for serialization and deserialization (e.g., `import dill; dill.dump(obj, file)`). For classes defined in `__main__` or when pickling modules, setting `dill.settings['recurse'] = True` before pickling can help `dill` trace and serialize global objects more comprehensively.
UnpicklingError: pickle data was truncated
This error indicates that the `.pkl` file being loaded is incomplete or corrupted, most often because the file writing process (e.g., from `dill.dump()` or `dill.dump_session()`) was interrupted or failed to write all data to disk.
fix
Ensure that the `dill.dump()` or `dill.dump_session()` operation completes successfully, and that the file buffer is flushed (e.g., `f.flush(); os.fsync(f.fileno())` for file objects) if writing to disk. Verify there is sufficient disk space when creating the pickled file, and regenerate the file if it is corrupted.
TypeError: 'module' object is not callable
This error occurs when the `dill` module itself is mistakenly called as a function (e.g., `dill(...)`) instead of invoking its specific functions (like `dill.load()` or `dill.dumps()`). It can also rarely indicate an incorrect import of another module like `pprint` in older contexts.
fix
Correct the function call to use the appropriate `dill` method, such as `dill.load(file)` or `dill.dumps(obj)`. If the error context involves `pprint`, ensure it's imported correctly, e.g., `from pprint import pprint` if `pprint` is intended to be used as a function.
Upgrade
Version history
0.4.1latest on PyPI · released Jan 19, 2026
Audit
Dependencies
setuptoolsrequiredRequired for installation
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources