dill
is a great tool for pickling most the Python objects, I use it in IPython parallel to serialize calculations. One issue I keep getting into is around dill-ing class definitions. One of the errors I get is explained below.
While trying to serialize class definitions, I keep getting AssertionError
from dill
. I wonder why one of these works and the other fails:
class MyClassEmpty(object):
pass
class MyClassInit(object):
def __init__(self):
super(MyClassInit).__init__()
dill.dumps(MyClassEmpty) # returns: '\x80\x02cdill.dill\n_create_type\nq\x00(cdill.dill\n_load_type\nq\x01U\x08TypeTypeq\x02\x85q\x03Rq\x04U\x0cMyClassEmptyq\x05h\x01U\nObjectTypeq\x06\x85q\x07Rq\x08\x85q\t}q\n(U\n__module__q\x0bU\x08__main__q\x0cU\x07__doc__q\rNutq\x0eRq\x0f.'
dill.dumps(MyClassInit) # AssertionError at line 244 of MyClassEmpty (assert id(obj) not in self.memo)
I'm on Python 2.7.6 using dill 0.2.2.
super
call seems incorrect - that should besuper(MyClassInit, self).__init__()
. – Reverend, self
. Having correcteddumps()
just works as expected, as in the linked post as well. – Angelynanger