[Pyrex] Wrapping a large number of #defines

Phil Frost indigo at bitglue.com
Fri Dec 10 00:16:01 CET 2004


You probably want a .pxd. They are documented at
<http://nz.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/sharing.html>.

On Thu, Dec 09, 2004 at 05:55:10PM -0500, Wes Kurdziolek wrote:
> 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