On Dec 14, 2009, at 8:27 AM, Dan Stromberg wrote:

> Stefan Behnel wrote:
>> Dan Stromberg, 14.12.2009 02:51:
>>
>>> Has anyone already worked out a system for preprocessing (maybe  
>>> via m4)
>>> a single input file into two output files: one a plain .py, and on  
>>> a .pyx?
>>>
>>> I sometimes prefer a pure python version of a dependency if I can  
>>> get
>>> it, because it makes the ongoing maintenance costs lower than  
>>> compiling
>>> (and recompiling) extension modules would.  It seems like due to the
>>> similarities between .py and .pyx, there should be a way of  
>>> maintaining
>>> both as a single document - so people who want the speed can have  
>>> it,
>>> and people who want convenience can have that, but the programmer
>>> doesn't end up maintaining two versions of said dependency.
>>>
>>> I googled, but didn't find anything that looked relevant, other than
>>> pages about how to use various preprocessors.
>>>
>>
>> I assume you know that Cython can compile .py files and has a pure  
>> Python
>> syntax for type declarations?
>>
>> http://wiki.cython.org/pure
>>
>> Stefan
>>
> Actually, I didn't know that.  It's interesting, but I don't think  
> it's
> what I want; I'm looking for something that will allow my code to not
> depend on cython at all in one form.

The @cython decorators in pure mode are all noops, so in that sense it  
doesn't depend on Cython.

> I've since worked out some simple ifdef's in m4 to do what I wanted.

Good. I remember a big discussion about preparsing long ago, and I  
think the consensus was to have people use an external tool rather  
than build anything into Cython itself (though perhaps making it  
easier to integrate).

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to