logo       

Re[2]: How do I subtype python internal type that is not part of a module?: msg#00044

python.pyrex

Subject: Re[2]: How do I subtype python internal type that is not part of a module?

On Mon, 19 Apr 2004 19:52:06 +1200 Greg Ewing <greg@xxxxxxxxxxxxxxxxxxxxx>
wrote:

> Lenard Lindstrom <len-l@xxxxxxxxx>:
>
> > 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@xxxxxxxxx>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise