[Pyrex] Wrapping a large number of #defines

Wes Kurdziolek wkurdziolek at devis.com
Thu Dec 9 23:55:10 CET 2004


For a project at work, I'm splitting up several old C programs into 
functions, some of which end up wrapped in Python via Pyrex.  However, 
some of our Python needs access to quite a few constants defined via 
#define in a C header file, and I was wondering if anyone had an easy 
way of wrapping them.  Our current proposed solution is to create a 
seperate pyx file (_constants.pyx, say) w/ a cdef enum block listing all 
the constants and beneath that assign the wrapped values to module-level 
variables that can be accessed when the resulting _constants.so is 
imported.  This works, but if there's an easier and less time-consuming 
way of doing it, I'd love to hear it.  Thanks!

Wes Kurdziolek
wkurdziolek at devis.com



More information about the Pyrex mailing list