Using alternative PyObject* in dynamically created classes
Jacek Generowicz
jacek.generowicz at cern.ch
Tue Nov 23 11:47:09 EST 2004
Thomas Heller <theller at python.net> writes:
> Jacek Generowicz <jacek.generowicz at cern.ch> writes:
>
> > Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> >> So my first attempt merely resets tp_basicsize to the size of my
> >> alternative instance struct, as soon as the class is created. This
> >> goes horribly wrong when instances of the class are deallocated, but I
> >> can't see why.
OK ... type_new augments the size it finds in tp_basicsize with space
for extra slots ... so resetting tp_basicsize once the type has been
created is indeed too late.
> Can't you simply create a new, subclassable Python type with an
> additonal void* slot, and derive your classes from it? Where's the
> problem?
You mean statically create an extension type with the appropriate size
in the tp_basicsize, and dynamically create types which inherit from
it?
Sounds like it should work.
I'll give it a go, as I now see that my initial approach is guaranteed
to be wrong.
Thanks.
More information about the Python-list
mailing list