[Cython] [Pyrex] ANN: Pyrex 0.9.7
Robert Bradshaw
robertwb at math.washington.edu
Sun May 11 10:28:02 CEST 2008
On May 10, 2008, at 3:03 PM, Lisandro Dalcin wrote:
> On 5/10/08, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> I don't quite see why we shouldn't just always convert
>>
>> for var in range(begin, end):
>>
>> to
>>
>> for var in begin <= var < end:
>>
>>
>> *iff* var is cdef-ed as a C integer type.
>
> I'm definitely +1 on this!!
This is actually enabled in the current version of Cython: http://
hg.cython.org/cython/file/0927890724ab/Cython/Compiler/Options.py
> Regarding to the overflow issue, perhaps
> a check can be added before entering the loop.
This is the semantic difference--if there will be an overflow then
Cython throws an error before entering the loop (rather than looping
until an overflow would occur). I think this is acceptable.
> And Cython should take
> care if the user modifies the range() arguments inside de loop. What
> will you do in this case? IMHO, matching the Python semantics is the
> right way.
One can't do that (in Python or Cython) as range() is evaluated
exactly once, before entering the loop, so this is a non-issue.
- Robert
More information about the Cython-dev
mailing list