subclassing "object" class in C?
jeremy at zope.com
Mon Apr 7 21:27:46 CEST 2003
On Mon, 07 Apr 2003 18:18:04 GMT
Maciej Kalisiak <mac at die.spammer.die.dgp.toronto.edu>
> How does one subclass the "object" class in C? A lot of
> examples I've seen of
> writing picklable subclasses in Python first subclass
> "object" (e.g. PEP 307).
> I'd like to do this in C, as that's where I'm writing an
> extension class/type.
Actually, you should make your C type a subclass of
PyType_Type. This is the C equivalent of saying
You might look at the datetime classes, implemented in C,
as examples of how you would write a picklable type in C.
In my very limited experience, it is harder than I
One thing you can do is define a helper function that makes
new instances and define a __reduce__ method on your class
that returns this helper function as the first argument.
More information about the Python-list