[Python-Dev] more on pickling

Martin v. Löwis martin at v.loewis.de
Tue Nov 18 01:08:58 EST 2003


Christian Tismer <tismer at tismer.com> writes:

> So I have the impression these methods loose their
> relationship to their originating object.
> Is this behavior by intent, i.e. is it impossible to write
> a working __reduce__ method for a bound class method?

I don't think it is impossible; see also python.org/sf/558238 

However, I would make pickling of bound methods "built-in", i.e. by
pickle explicitly recognizing bound methods, or using copy_reg, as
Konrad suggests.

If you really want to use __reduce__, you probably have to make sure
it isn't delegated to the function object.

Regards,
Martin



More information about the Python-Dev mailing list