[docs] [issue35933] python doc does not say that the state kwarg in Pickler.save_reduce can be a tuple (and not only a dict)

Pierre Glaser report at bugs.python.org
Wed Feb 20 10:41:42 EST 2019


Pierre Glaser <pierreglaser at msn.com> added the comment:

I added a PR with a small patch to document this behavior and reconcile _pickle.c and pickle.py

Some explanations on why I am pushing this forward:
 
Pickling instances of classes/subclasses with slots is done natively for pickle protocol >= 2. Mentioning this behavior in the docs should *not* make the user worry about implementing custom __getstate__ methods just to preserve slots.

Here is the reason why I think this functionality (allowing state and slotstate) is worth documenting: pickle gives us a lot of flexibility for reducing thanks to the dispatch_table. But unpickling is rather rigid: if no __setstate__ exists, we have to deal with the default state updating procedure present in load_build. Might as well document all of it ;)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35933>
_______________________________________


More information about the docs mailing list