On Mar 17, 2009, at 2:35 PM, Greg Ewing wrote:
> Dag Sverre Seljebotn wrote:
>
>> ForFromStatNode is used in two situations in Cython code; in the
>> Cython-specific syntax
>>
>> cdef int i
>> for i from start <= i < end [by step]:
>> ...
>>
>> In the former case, end should NOT be frozen (i.e. if it is a
>> function
>> call it should be called again for every iteration
>
> Has Cython changed this? It's not how the for-from
> statement works in Pyrex -- the limits are only
> evaluated once.
No, Cython has not changed this, and I'm not sure we should. But
there is some inconsistency:
%cython
cdef int get_bound(int m):
print "get_bound(%s)"%m
return m
def test_var(int n, int m):
cdef int i
for i from 0 <= i < n:
print "at", i
n = m
return i
def test_func(int n):
cdef int i
for i from 0 <= i < get_bound(n):
print "at", i
return i
sage: test_var(10, 5)
at 0
at 1
at 2
at 3
at 4
5
sage: test_func(5)
get_bound(5)
at 0
at 1
at 2
at 3
at 4
5
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev