[issue4712] Document pickle behavior for subclasses of dicts/lists

Raymond Hettinger report at bugs.python.org
Tue Mar 3 22:04:42 CET 2009

Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

The behavior is a PITA.  It means that dict subclasses the redefine
__setitem__ have unpleasant pickling challenges.  The __setitem__
insertions are called before the subclass can initialize.

The workaround involves a funky dance using __reduce__.  See
collections.OrderedDict::__reduce__() for an example.

nosy: +rhettinger
priority: low -> normal

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list