[Python-3000] Simplifying the copy protocol
Guido van Rossum
guido at python.org
Fri Jun 20 00:11:16 CEST 2008
I haven't had the time to look into this, but it sounds unintuitive to
drop __reduce_ex__ which is supposed to be the "extended" IOW "newer"
version of the API compared to __reduce__ which was deemed to be
missing something.
On Thu, Jun 19, 2008 at 2:19 PM, Alexandre Vassalotti
<alexandre at peadrop.com> wrote:
> 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.
>
>
> -- Alexandre
>
>
> 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.
>>
>> Cheers,
>> -- Alexandre
>>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list