pickling extension types

benevilent at optusnet.com.au benevilent at optusnet.com.au
Tue Aug 10 07:34:30 EDT 2004


Hey,

I am creating an extension type in C for Python, which I want it such
that instances can be pickled. I basically want the functionality of the
'object' type such that subclasses of the type which I define, can
define methods including __getstate__ which will get called on
pickling/unpickling.

To do this I need to define the __reduce__ method. The __reduce__ method
in typeobject.c is exactly what I need for this task. Is there a way to
reuse this without copy-pasting the code?

Thanks,
Laurie



More information about the Python-list mailing list