[Python-3000] Simplifying the copy protocol
alexandre at peadrop.com
Thu Jun 19 23:19:13 CEST 2008
Any comment on the proposed changes? Well if no-one objects, I would
like to move forward and implement these changes:
- Deprecate __reduce_ex__ and copyreg.pickle in 2.6 and 3.0 (with a
planned removal in 3.1).
- Make __reduce__ raise a TypeError on the condition previously
described in 3.0.
On Sun, Jun 8, 2008 at 6:26 PM, Alexandre Vassalotti
<alexandre at peadrop.com> wrote:
> Hello all,
> I would like to propose to following simplifications to the copy
> protocol (a.k.a the __reduce__ method):
> - Remove the type.__reduce_ex__ method and define __reduce__ method
> to take a single optional integer argument that is the pickle protocol
> version to use. And since this already the current behavior of
> __reduce__, no change is required.
> - Deprecate copyreg.pickle in favor of the __getnewargs__ special
> method. They both solve the exact same problem, but __getnewargs__
> does it in a simpler and more robust manner.
> - Make __reduce__ raise a TypeError if the class of an instance
> derives from one or more extension type (object, list and dict
> excluded) and neither __getnewargs__ nor __getstate__ is defined.
> I believe that these changes will make it easier for developers to
> write classes that supports the copy protocol, which is already quite
> complex in addition of being poorly documented. Evidently, I will
> provide the patches and write the documentation for these changes.
> -- Alexandre
More information about the Python-3000