[Pyrex] Pyrex at Pycon

Matthias Baas baas at ira.uka.de
Tue Mar 30 17:51:23 CEST 2004


Greg Ewing wrote:
> Paul Prescod <paul at prescod.net>:
>>When I had some extra time on a plane I started to write up a 
>>PEP-like-thing. My proposal is that macros are expanded by the 
>>preprocessor and Pyrex works on the expanded output.

I second that approach!

> What about #defines used as constants? Probably
> you'll want them turned into enums and/or module
> attributes.

Well, you already say it yourself: "probably". So this needs user 
interaction, as I don't see a way to reliably predict how to process one 
particular #define. And unless you're planning on making Pyrex an 
interactive tool this user interaction could just as well be editing the 
generated Pyrex file and filling in the missing #defines in whatever way 
the user considers appropriate.
Of course, it would be nice if Pyrex could output a report that contains 
all #defines so that I can go through them and decide how to add them to 
the *.pyx file. It would even be nicer if that report would already 
include one or more default wrappings from which I can choose and copy & 
paste it to the final *.pyx file.

> What about #include directives? Most of the time
> you probably don't want to expand them, otherwise
> you'd end up wrapping all the system header files.

The preprocessor output still contains lines that name the input file 
from which the following lines are taken. So it'll still be possible to 
ignore lines that are not from the currently processed file or that are 
stored in an entirely different directory tree, etc.

- Matthias -





More information about the Pyrex mailing list