[Pyrex] A problem in generating Python extension types.
Daehyok Shin
sdhyok at gmail.com
Sun Jan 14 03:36:17 UTC 2007
I am trying to replace complex C structures with Python extension
types generated from PyRex code. My purpose is to create Python
extension types which allows other C programs to access structure
variables inside the extension types.
A problem I met during the development may be best explained with the
following simple example.
--------- C Code --------------------------------
struct child_object {
int ID;
}
struct parent_object {
struct child_object *child;
}
---------- PyRex Code ------------------------
public Child[object child_object, type child_type]:
cdef public int ID
public Parent[object parent_object, type parent_type]:
cdef Child child
def __new__(self)
self.child = Child() # I got an error message here when compiling
generated C code.
def __dealloc_(self):
del self.child
I succeeded in creating the same C structures from the above PyRex
code, but when I compiled the generated C code, I got an error message
because self.child expects a pointer to child_object but Child()
returns a pointer to PyObject.
Is there any way I can solve this problem so that the extension types
act as a commond data models for both Python programs and C programs.
Thanks in advance.
Shin
More information about the Pyrex
mailing list