I am using dill (advanced version of pickle) right now. I want to serialize my object, but I get this error:
/usr/lib/python2.7/pickle.pyc in memoize(self, obj)
242 if self.fast:
243 return
--> 244 assert id(obj) not in self.memo
245 memo_len = len(self.memo)
246 self.write(self.put(memo_len))
Can someone tell me the possibility that made this error or how can I solved this?
dill
is violating apickle
invariant; recursive structures should not lead to circular references being pickled again.self.memo
tracks what has already been pickled before. – Possingdill
but theid(obj) not in self.memo
assert is triggered ifid(obj)
has been seen before. – Possingdill
author. It's just a big collection of usingcopy_reg
for different objects, and I don't violate anypickle
invariants… I do however do a few workarounds so all sorts of objects are added to thememo
ofpickle
when you importdill
. There's no duplication in adding to memo, unless you do something weird likeimport pickle
, thencopy_reg
some stuff, thenimport dill
-- and that's probably even fine in many cases. – Stunkdill
internals at all. It sounds as if the OP should try to produce a minimal example that triggers the problem? – Possingdill
usespickle
; but follow Mike's advice. – Possingdetect
methods you have tried as shown below in my post. It's much harder to help w/o seeing what you are seeing. – Stunk