[Numpy-discussion] [ANN] Cython 0.15

Sturla Molden sturla@molden...
Mon Aug 8 10:29:38 CDT 2011

Den 08.08.2011 11:47, skrev Dag Sverre Seljebotn:
> This come up now and again and I believe there's several 
> half-baked/started solutions out there by Cython users, but nothing 
> that is standard or that I know is carried out to completion. I.e., 
> you should ask on the cython-users list. It'd be good if somebody 
> would compile a list of the efforts so far on the wiki as well...

I wrote a mock-up pxd-generator for the OpenGL headers. It only worked 
with a particular set of OpenGL header files, and the output still 
required a few cases of manual editing. But this still saved me a lot of 
time re-declaring OpenGL to Cython, and an important benefit is 
correctness (i.e. almost no manual code to proof) :) The script is so 
bad, though, I am not sure I want to show it to anyone ;-)

Writing a general "headerfile2pxd.py" script is a huge undertaking.

The C preprocessor makes this particularly annoying, because some 
symbols might be defined at compile-time. To make things worse, C 
headers can also be recursive. Running the preprocessor in advance is 
not an option either, because some C APIs rely heavily on defined 
symbols. These will not survive through the preprocessor. Sometimes we 
want to fool Cython into thinking that a defined constant is an external 
variable or function with some C types, which also complicates this 
effort. It's not that bad if we write a generator for a particular set 
of header files, but a PITA when we write one for general use.


More information about the NumPy-Discussion mailing list