Using alternative PyObject* in dynamically created classes
jacek.generowicz at cern.ch
Wed Nov 24 14:20:43 CET 2004
Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> Thomas Heller <theller at python.net> writes:
> > Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> > 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
> Sounds like it should work.
> I'll give it a go, as I now see that my initial approach is guaranteed
> to be wrong.
Given that type_new builds the contents of the tp_basicsize slot on
the basis of the supreclass's tp_basicsize, it seems that setting the
size in a superclass is the only way of getting some non-standard size
in there, without re-writing the whole of type_new.
So, I tried this approach. It works.
More information about the Python-list