Package: dill-pylint
About Dilldillextends python’spicklemodule for serializing and de-serializing
python objects to the majority of the built-in python types. Serialization
is the process of converting an object to a byte stream, and the inverse
of which is converting a byte stream back to a python object hierarchy.dillprovides the user the same interface as thepicklemodule, and
also includes some additional features. In addition to pickling python
objects,dillprovides the ability to save the state of an interpreter
session in a single command.  Hence, it would be feasible to save an
interpreter session, close the interpreter, ship the pickled file to
another computer, open a new interpreter, unpickle the session and
thus continue from the ‘saved’ state of the original interpreter
session.dillcan be used to store python objects to a file, but the primary
usage is to send python objects across the network as a byte stream.dillis quite flexible, and allows arbitrary user defined classes
and functions to be serialized.  Thusdillis not intended to be
secure against erroneously or maliciously constructed data. It is
left to the user to decide whether the data they unpickle is from
a trustworthy source.dillis part ofpathos, a python framework for heterogeneous computing.dillis in active development, so any user feedback, bug reports, comments,
or suggestions are highly appreciated.  A list of issues is located athttps://github.com/uqfoundation/dill/issues, with a legacy list maintained athttps://uqfoundation.github.io/project/pathos/query.Major Featuresdillcan pickle the following standard types:none, type, bool, int, float, complex, bytes, str,tuple, list, dict, file, buffer, builtin,python classes, namedtuples, dataclasses, metaclasses,instances of classes,set, frozenset, array, functions, exceptionsdillcan also pickle more ‘exotic’ standard types:functions with yields, nested functions, lambdas,cell, method, unboundmethod, module, code, methodwrapper,methoddescriptor, getsetdescriptor, memberdescriptor, wrapperdescriptor,dictproxy, slice, notimplemented, ellipsis, quitdillcannot yet pickle these standard types:frame, generator, tracebackdillalso provides the capability to:save and load python interpreter sessionssave and extract the source code from functions and classesinteractively diagnose pickling errorsCurrent ReleaseThe latest released version ofdillis available from:https://pypi.org/project/dilldillis distributed under a 3-clause BSD license.Development VersionYou can get the latest development version with all the shiny new features at:https://github.com/uqfoundationIf you have a new contribution, please submit a pull request.Installationdillcan be installed withpip:$ pip install dillTo optionally include theobjgraphdiagnostic tool in the install:$ pip install dill[graph]For windows users, to optionally install session history tools:$ pip install dill[readline]Requirementsdillrequires:python(orpypy),>=3.7setuptools,>=42Optional requirements:objgraph,>=1.7.2pyreadline,>=1.7.1(on windows)Basic Usagedillis a drop-in replacement forpickle. Existing code can be
updated to allow complete pickling using:>>> import dill as pickleor:>>> from dill import dumps, loadsdumpsconverts the object to a unique byte string, andloadsperforms
the inverse operation:>>> squared = lambda x: x**2
>>> loads(dumps(squared))(3)
9There are a number of options to control serialization which are provided
as keyword arguments to severaldillfunctions:withprotocol, the pickle protocol level can be set. This uses the
same value as thepicklemodule,DEFAULT_PROTOCOL.withbyref=True,dillto behave a lot more like pickle with
certain objects (like modules) pickled by reference as opposed to
attempting to pickle the object itself.withrecurse=True, objects referred to in the global dictionary are
recursively traced and pickled, instead of the default behavior of
attempting to store the entire global dictionary.withfmode, the contents of the file can be pickled along with the file
handle, which is useful if the object is being sent over the wire to a
remote system which does not have the original file on disk. Options areHANDLE_FMODEfor just the handle,CONTENTS_FMODEfor the file content
andFILE_FMODEfor content and handle.withignore=False, objects reconstructed with types defined in the
top-level script environment use the existing type in the environment
rather than a possibly different reconstructed type.The default serialization can also be set globally indill.settings.
Thus, we can modify howdillhandles references to the global dictionary
locally or globally:>>> import dill.settings
>>> dumps(absolute) == dumps(absolute, recurse=True)
False
>>> dill.settings['recurse'] = True
>>> dumps(absolute) == dumps(absolute, recurse=True)
Truedillalso includes source code inspection, as an alternate to pickling:>>> import dill.source
>>> print(dill.source.getsource(squared))
squared = lambda x:x**2To aid in debugging pickling issues, usedill.detectwhich provides
tools like pickle tracing:>>> import dill.detect
>>> with dill.detect.trace():
>>>     dumps(squared)
┬ F1: <function <lambda> at 0x7fe074f8c280>
├┬ F2: <function _create_function at 0x7fe074c49c10>
│└ # F2 [34 B]
├┬ Co: <code object <lambda> at 0x7fe07501eb30, file "<stdin>", line 1>
│├┬ F2: <function _create_code at 0x7fe074c49ca0>
││└ # F2 [19 B]
│└ # Co [87 B]
├┬ D1: <dict object at 0x7fe0750d4680>
│└ # D1 [22 B]
├┬ D2: <dict object at 0x7fe074c5a1c0>
│└ # D2 [2 B]
├┬ D2: <dict object at 0x7fe074f903c0>
│├┬ D2: <dict object at 0x7fe074f8ebc0>
││└ # D2 [2 B]
│└ # D2 [23 B]
└ # F1 [180 B]With trace, we see howdillstored the lambda (F1) by first storing_create_function, the underlying code object (Co) and_create_code(which is used to handle code objects), then we handle the reference to
the global dict (D2) plus other dictionaries (D1andD2) that
save the lambda object’s state. A#marks when the object is actually stored.More InformationProbably the best way to get started is to look at the documentation athttp://dill.rtfd.io. Also seedill.testsfor a set of scripts that
demonstrate howdillcan serialize different python objects. You can
run the test suite withpython-mdill.tests. The contents of any
pickle file can be examined withundill.  Asdillconforms to
thepickleinterface, the examples and documentation found athttp://docs.python.org/library/pickle.htmlalso apply todillif one willimport dill as pickle. The source code is also generally
well documented, so further questions may be resolved by inspecting the
code itself. Please feel free to submit a ticket on github, or ask a
question on stackoverflow (@Mike McKerns).
If you would like to share how you usedillin your work, please send
an email (tommckerns at uqfoundation dot org).CitationIf you usedillto do research that leads to publication, we ask that you
acknowledge use ofdillby citing the following in your publication:M.M. McKerns, L. Strand, T. Sullivan, A. Fang, M.A.G. Aivazis,
"Building a framework for predictive science", Proceedings of
the 10th Python in Science Conference, 2011;
http://arxiv.org/pdf/1202.1056

Michael McKerns and Michael Aivazis,
"pathos: a framework for heterogeneous computing", 2010- ;
https://uqfoundation.github.io/project/pathosPlease seehttps://uqfoundation.github.io/project/pathosorhttp://arxiv.org/pdf/1202.1056for further information.