[Python-ideas] Make __reduce__ to correspond to __getnewargs_ex__
Neil Girdhar
mistersheik at gmail.com
Sun Mar 23 23:20:41 CET 2014
Currently __reduce__<http://docs.python.org/3.4/library/pickle.html#object.__reduce__>returns up to five things:
(1) self.__new__ (or a substitute)
(2) the result of __getnewargs__<http://docs.python.org/3.4/library/pickle.html#object.__getnewargs__>,
which returns a tuple of positional arguments for __new__<http://docs.python.org/3.4/reference/datamodel.html#object.__new__>
,
(3) the result of __getstate__<http://docs.python.org/3.4/library/pickle.html#object.__getstate__>,
which returns an object to be passed to __setstate__<http://docs.python.org/3.4/library/pickle.html#object.__setstate__>
(4) an iterator of values for appending to a sequence
(5) an iterator of key-value pairs for setting on a string.
Python 3.4 added the very useful (for me) __getnewargs_ex__<http://docs.python.org/3.4/library/pickle.html#object.__getnewargs_ex__>,
which returns a pair:
(1) a tuple of positional arguments for __new__<http://docs.python.org/3.4/reference/datamodel.html#object.__new__>
(2) a dict of keyword arguments for __new__<http://docs.python.org/3.4/reference/datamodel.html#object.__new__>
Therefore, I am proposing that __reduce__ return somehow these keyword
arguments for __new__.
Best,
Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140323/5fac6a92/attachment.html>
More information about the Python-ideas
mailing list