|
How do I subtype python internal type that is not part of a module?: msg#00034python.pyrex
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: # func.pyx # Useful subtypes of function type. cdef extern from "python.h": ctypedef class function [object PyFunctionObject, type PyFunction_Type]: pass cdef object PyMethod_New(object func, object self, object type) cdef class classfunction(function): def __get__(self, obj, typ): if typ is None: typ = type(typ) return PyMethod_New(self, typ, type(typ)) cdef class staticfunction(function): def __get__(self, obj, typ): return self and it generates the following messages at compile time: ...\func.pyx:5:4: Module name required for 'extern' C class ...\func.pyx:5:4: Type object name specification not allowed for 'extern' C class I cannot give a module name because there is none; the python 'types' and 'new' modules are coded in python and use something like function = type(lambda: None) to get the function type. Even that does not work: # func.pyx # Useful subtypes of function type. cdef extern from "python.h": object PyMethod_New(object func, object self, object type) function = type(lambda: None) . . . ...\func.pyx:7:16: Expected an identifier or literal Any suggestions? Lenard Lindstrom <len-l@xxxxxxxxx> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: successfully using gcc to generate extensions for windows: 00034, Voidspace |
|---|---|
| Next by Date: | How to efficiently construct an extension instance from Pyrex?: 00034, Gary Bishop |
| Previous by Thread: | Newbie Questioni: 00034, Michael |
| Next by Thread: | Re: How do I subtype python internal type that is not part of a module?: 00034, Greg Ewing |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |