dill

serialize all of Python

https://github.com/uqfoundation/dill

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    3 of 47 committers (6.4%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.1%) to scientific vocabulary

Keywords from Contributors

alignment flexible distribution parallel packaging unit-testing asyncio attribution interactive closember
Last synced: 6 months ago · JSON representation

Repository

serialize all of Python

Basic Info
  • Host: GitHub
  • Owner: uqfoundation
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage: http://dill.rtfd.io
  • Size: 1.53 MB
Statistics
  • Stars: 2,371
  • Watchers: 24
  • Forks: 181
  • Open Issues: 194
  • Releases: 27
Created over 12 years ago · Last pushed 8 months ago
Metadata Files
Readme License

README.md

dill

serialize all of Python

About Dill

dill extends Python's pickle module 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.

dill provides the user the same interface as the pickle module, and also includes some additional features. In addition to pickling Python objects, dill provides 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.

dill can 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. dill is quite flexible, and allows arbitrary user defined classes and functions to be serialized. Thus dill is 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.

dill is part of pathos, a Python framework for heterogeneous computing. dill is in active development, so any user feedback, bug reports, comments, or suggestions are highly appreciated. A list of issues is located at https://github.com/uqfoundation/dill/issues, with a legacy list maintained at https://uqfoundation.github.io/project/pathos/query.

Major Features

dill can 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, exceptions

dill can 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, quit

dill cannot yet pickle these standard types:

  • frame, generator, traceback

dill also provides the capability to:

  • save and load Python interpreter sessions
  • save and extract the source code from functions and classes
  • interactively diagnose pickling errors

Current Release Downloads Conda Downloads

Stack Overflow

The latest released version of dill is available from: https://pypi.org/project/dill

dill is distributed under a 3-clause BSD license.

Development Version Support Documentation Status Build Status

codecov

You can get the latest development version with all the shiny new features at: https://github.com/uqfoundation

If you have a new contribution, please submit a pull request.

Installation

dill can be installed with pip::

$ pip install dill

To optionally include the objgraph diagnostic tool in the install::

$ pip install dill[graph]

To optionally include the gprof2dot diagnostic tool in the install::

$ pip install dill[profile]

For windows users, to optionally install session history tools::

$ pip install dill[readline]

Requirements

dill requires:

  • python (or pypy), >=3.9
  • setuptools, >=42

Optional requirements:

  • objgraph, >=1.7.2
  • gprof2dot, >=2022.7.29
  • pyreadline, >=1.7.1 (on windows)

Basic Usage

dill is a drop-in replacement for pickle. Existing code can be updated to allow complete pickling using::

>>> import dill as pickle

or::

>>> from dill import dumps, loads

dumps converts the object to a unique byte string, and loads performs the inverse operation::

>>> squared = lambda x: x**2
>>> loads(dumps(squared))(3)
9

There are a number of options to control serialization which are provided as keyword arguments to several dill functions:

  • with protocol, the pickle protocol level can be set. This uses the same value as the pickle module, DEFAULT_PROTOCOL.
  • with byref=True, dill to behave a lot more like pickle with certain objects (like modules) pickled by reference as opposed to attempting to pickle the object itself.
  • with recurse=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.
  • with fmode, 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 are HANDLE_FMODE for just the handle, CONTENTS_FMODE for the file content and FILE_FMODE for content and handle.
  • with ignore=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 in dill.settings. Thus, we can modify how dill handles 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)
True

dill also includes source code inspection, as an alternate to pickling::

>>> import dill.source
>>> print(dill.source.getsource(squared))
squared = lambda x:x**2

To aid in debugging pickling issues, use dill.detect which 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 how dill stored 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 (D1 and D2) that save the lambda object's state. A # marks when the object is actually stored.

More Information

Probably the best way to get started is to look at the documentation at http://dill.rtfd.io. Also see dill.tests for a set of scripts that demonstrate how dill can serialize different Python objects. You can run the test suite with python -m dill.tests. The contents of any pickle file can be examined with undill. As dill conforms to the pickle interface, the examples and documentation found at http://docs.python.org/library/pickle.html also apply to dill if one will import 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 use dill in your work, please send an email (to mmckerns at uqfoundation dot org).

Citation

If you use dill to do research that leads to publication, we ask that you acknowledge use of dill by 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/pathos

Please see https://uqfoundation.github.io/project/pathos or http://arxiv.org/pdf/1202.1056 for further information.

Owner

  • Name: The UQ Foundation
  • Login: uqfoundation
  • Kind: organization
  • Email: info@uqfoundation.org
  • Location: Wilmington, DE

A nonprofit dedicated to the advancement of predictive science through research partnerships and education.

GitHub Events

Total
  • Create event: 18
  • Release event: 1
  • Issues event: 26
  • Watch event: 115
  • Delete event: 15
  • Issue comment event: 59
  • Push event: 25
  • Pull request review event: 3
  • Pull request event: 34
  • Fork event: 5
Last Year
  • Create event: 18
  • Release event: 1
  • Issues event: 26
  • Watch event: 115
  • Delete event: 15
  • Issue comment event: 59
  • Push event: 25
  • Pull request review event: 3
  • Pull request event: 34
  • Fork event: 5

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 686
  • Total Committers: 47
  • Avg Commits per committer: 14.596
  • Development Distribution Score (DDS): 0.22
Past Year
  • Commits: 31
  • Committers: 5
  • Avg Commits per committer: 6.2
  • Development Distribution Score (DDS): 0.258
Top Committers
Name Email Commits
mmckerns m****s@8****f 535
Matthew Joyce m****e@g****m 48
Anirudh Vegesana a****a@g****m 14
Leonardo Gama l****a@g****m 14
dependabot[bot] 4****] 13
Miguel Sánchez de León Peque p****e@n****s 11
Gabi Davar g****o@g****m 3
Hugo h****k 3
yoshiki obata y****a@g****m 2
Michał Górny m****y@g****g 2
Kernc k****e@g****m 2
Kengo Seki s****n@a****g 2
Jason Myers j****s@b****m 2
Bob Fischer r****6@c****u 2
Sergei Fomin s****a@y****u 1
Paul Kienzle p****e@g****m 1
Nick White n****e@p****m 1
0xflotus 0****s@g****m 1
Adam Williamson a****m@b****a 1
Albert Villanova del Moral 8****a 1
Eugene Toder e****r 1
Futrell f****l@m****u 1
James Laird-Wah j****l@m****g 1
tmshn s****r@g****m 1
roryk r****r@g****m 1
robbe r****s@m****u 1
lilinjie 1****e 1
ernstklrb e****g@d****m 1
angschmi 6****i 1
Zhaoyang Li z****i@o****m 1
and 17 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 151
  • Total pull requests: 100
  • Average time to close issues: 12 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 124
  • Total pull request authors: 22
  • Average comments per issue: 4.25
  • Average comments per pull request: 1.71
  • Merged pull requests: 72
  • Bot issues: 0
  • Bot pull requests: 23
Past Year
  • Issues: 18
  • Pull requests: 44
  • Average time to close issues: 20 days
  • Average time to close pull requests: 2 days
  • Issue authors: 15
  • Pull request authors: 6
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.55
  • Merged pull requests: 33
  • Bot issues: 0
  • Bot pull requests: 13
Top Authors
Issue Authors
  • mmckerns (16)
  • mgorny (4)
  • benclifford (3)
  • dfremont (2)
  • kloczek (2)
  • neucer (2)
  • stammler (2)
  • dionhaefner (2)
  • NiklasRosenstein (2)
  • cdzhan (2)
  • tvalentyn (2)
  • hugovk (1)
  • qq745639151 (1)
  • amanjn98 (1)
  • baeminbo (1)
Pull Request Authors
  • mmckerns (51)
  • dependabot[bot] (31)
  • leogama (13)
  • anivegesana (5)
  • kelvinburke (2)
  • Seraphli (2)
  • timkpaine (2)
  • hroncok (2)
  • lizy14 (2)
  • mgorny (2)
  • kloczek (2)
  • charmoniumQ (1)
  • ryanthompson591 (1)
  • uniontech-lilinjie (1)
  • KOLANICH (1)
Top Labels
Issue Labels
question (18) compatibility (15) bug (14) voided (14) duplicate (13) wontfix (7) enhancement (6) bugfix (1) dependencies (1)
Pull Request Labels
dependencies (37) compatibility (36) bugfix (19) enhancement (13) python (5) duplicate (3) voided (3) refactor (1)

Packages

  • Total packages: 5
  • Total downloads:
    • pypi 100,612,250 last-month
  • Total docker downloads: 1,798,719,056
  • Total dependent packages: 1,283
    (may contain duplicates)
  • Total dependent repositories: 26,451
    (may contain duplicates)
  • Total versions: 72
  • Total maintainers: 3
pypi.org: dill

serialize all of Python

  • Versions: 29
  • Dependent Packages: 1,127
  • Dependent Repositories: 25,888
  • Downloads: 100,612,186 Last month
  • Docker Downloads: 1,798,719,056
Rankings
Downloads: 0.0%
Dependent packages count: 0.0%
Dependent repos count: 0.0%
Docker downloads count: 0.1%
Average: 1.2%
Stargazers count: 2.1%
Forks count: 5.0%
Maintainers (1)
Last synced: 6 months ago
spack.io: py-dill

Serialize all of python

  • Versions: 17
  • Dependent Packages: 17
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 3.9%
Average: 4.4%
Stargazers count: 5.4%
Forks count: 8.3%
Maintainers (1)
Last synced: 11 months ago
conda-forge.org: dill

`dill` extends Python's `pickle` module for serializing and de-serializing Python objects to the majority of the built-in Python types.

  • Versions: 14
  • Dependent Packages: 118
  • Dependent Repositories: 281
Rankings
Dependent packages count: 0.7%
Dependent repos count: 1.9%
Average: 6.5%
Stargazers count: 9.1%
Forks count: 14.2%
Last synced: 6 months ago
anaconda.org: dill

Dill extends Python's 'pickle' module for serializing and de-serializing Python objects to the majority of the built-in python types.

  • Versions: 11
  • Dependent Packages: 21
  • Dependent Repositories: 281
Rankings
Dependent packages count: 1.7%
Dependent repos count: 11.0%
Average: 14.1%
Stargazers count: 18.0%
Forks count: 25.7%
Last synced: 6 months ago
pypi.org: dill-pylint

serialize all of python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 64 Last month
Rankings
Stargazers count: 1.6%
Forks count: 3.7%
Dependent packages count: 7.3%
Average: 15.8%
Dependent repos count: 22.1%
Downloads: 44.3%
Maintainers (1)
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • alabaster ==0.7.12
  • babel ==2.9.1
  • docutils ==0.16
  • imagesize ==1.3.0
  • importlib-metadata ==4.11.3
  • jinja2 ==3.1.1
  • markupsafe ==2.1.1
  • packaging ==21.3
  • pygments ==2.11.2
  • pyparsing ==3.0.8
  • readthedocs-sphinx-search ==0.1.1
  • requests ==2.27.1
  • sphinx ==4.5.0
  • sphinx-notfound-page ==0.8
  • sphinx-rtd-theme ==1.0.0