[Pyrex] How do I subtype python internal type that is not part of a module?

Lenard Lindstrom len-l at telus.net
Mon Apr 19 19:12:33 CEST 2004


On Mon, 19 Apr 2004 19:52:06 +1200 Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:

> Lenard Lindstrom <len-l at telus.net>:
> 
> > I have enhanced my python interpeter to allow subtyping of python
> > functions and wish to create some extension types directly from
> > PyFunction_Type. Unfortunately the type is not part of any module. I
> > have tried the following pyrex code:
> 
> It's available in the "types" module, so you should be
> able to say
>   
>   cdef extern from "python.h":
>     ctypedef class types.FunctionType [object PyFunctionObject]:
>       pass

Thank you. It worked. 

Just one thought though. Would it be useful if Pyrex provided some way to directly declare an extension
subtype from a PyType_Type instance declared in another C file? If one needs full control of memory
management for example, one would write a base type in C, then use Pyrex to create the extension 
module boiler plate and any subtypes. The Pyrex output file would be linked with the C base type file
to make the final extension module.

Lenard Lindstrom
<len-l at telus.net>







More information about the Pyrex mailing list