[Pyrex] cdef'd classes initialization

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Aug 10 02:06:33 UTC 2006


Lenard Lindstrom wrote:

> The tp_alloc slot function returns a valid object except for user 
> defined fields, which are zeroed memory. PyType_GenericNew() makes 
> the call without doing anything else. So this should be what is 
> wanted. The problem with Pyrex are C methods. So what is needed is 
> some kind of extension type specific allocation operation that calls 
> tp_alloc and sets the vtable field, if any.

There's also the problem of Python-valued C attributes --
these are also initialised to None in the tp_new code
that Pyrex generates. So that would need to be separated
out somehow as well.

And then there's also the issue of what happens when
you derive from another type that needs its tp_new called
in order to initialise it properly. You can't fully
separate allocation from initialisation in that case,
because the tp_alloc call happens at the bottom of the
chain of tp_new calls. And you can't avoid allocating
an argument tuple, because tp_new takes Python arguments.

--
Greg



More information about the Pyrex mailing list