talira

Extends Python's pickle to serialize almost any Python object

open sourceBSD-3-Clausefree

dill extends Python's pickle module to serialize and deserialize most built-in Python types, with the same interface as pickle. It can also pickle lambdas, nested functions, functions with yields, classes, modules and code objects that pickle can't, save and load a whole interpreter session, extract the source of functions and classes, and help diagnose pickling errors. Its main use is sending Python objects across the network as byte streams. It isn't secure against malicious data, so only unpickle data you trust. It's part of the pathos framework. Install it from PyPI as dill.

Problems it solves

  • pickle a lambda or nested function in Python without a PicklingError
  • send a Python function to another machine to run there
  • save my whole Python interpreter session and restore it later

Features

  • same interface as Python's pickle module
  • pickles lambdas, nested functions, classes, modules and code objects
  • saves and loads whole interpreter sessions
  • extracts the source code of functions and classes
  • tools to diagnose pickling errors

Limitations

  • Not secure against erroneously or maliciously constructed data: only unpickle data from a trusted source.1
  • Can't yet pickle frame, generator or traceback objects.1

Alternatives

The same job

These do what dill does.

  1. cloudpickle Pickle Python constructs the standard pickle module can't

Compare dill with the top 3