Questions tagged [dill]

Dill is a module which extends python's 'pickle' module for serializing and de-serializing python objects to the majority of the built-in python types. Use this tag in conjunction with the pickle and python tag for questions about object serialization with Dill.

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

Major features

Dill can pickle the following standard types:

  • none, type, bool, int, long, float, complex, str, unicode,
  • tuple, list, dict, file, buffer, builtin,
  • both old and new style classes,
  • instances of old and new style 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,
  • dictproxy, methoddescriptor, getsetdescriptor, memberdescriptor,
  • wrapperdescriptor, xrange, 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

The latest released version of dill is available from http://dev.danse.us/trac/pathos and https://github.com/uqfoundation/dill.

Dill is distributed under a 3-clause BSD license.

290 questions
-1
votes
1 answer

How to save complex class objects in dill?

I have a class object I want to pickle with dill: class A: def __init__(self, a): self.a = a a = A(5) with open('file.pkl', 'wb') as f: pickle.dump(a, f) This works I now want to make a copy like: class A: def __init__(self, a): …
Nathan
  • 3,558
  • 1
  • 18
  • 38
-1
votes
1 answer

Getting source code from dill pickle file (OSError: could not extract source code)

Reading further from this post how can we get source code from the pickle file I tried using getsource ( after reading this post)but that only works when class is defined in same session, below is the code that I tried class Foo(object): def…
sakeesh
  • 919
  • 1
  • 10
  • 24
-1
votes
1 answer

Python3 C-libs: How do I serialize a class that depends on C .dlls for use in a bare instance?

For example: // file foo def my_func(): print("foo!") // file bar class Bar: def __init__(self): pass def hello(): import foo.my_func my_func() import dill dill.dump(Bar(), open("bar.dpkl",mode='wb+')) $: python3 -m…
Chris
  • 28,822
  • 27
  • 83
  • 158
-1
votes
2 answers

Load Multiple files from Folder using dill in python?

I got a folder with 100 *.sav files, I have to load all in to a list, file names saved as my_files_0,my_files_1,my_files_2,my_files_3.... So, I tried: import dill my_files = [] files_name_list = glob.glob('c:/files/*.sav') for i in np.arange(1,…
hanzgs
  • 1,498
  • 17
  • 44
-2
votes
2 answers

TypeError: cannot pickle '_hashlib.HASH' object

I have a rather simple dataclass. I saved it on a pickle (using dill instead of the real pickle). import dill as pickle After some other operations: Loading the same pickle fails Trying to save the same object fails Error: TypeError: cannot pickle…
Rub
  • 2,071
  • 21
  • 37
1 2 3
19
20