Does it make any difference, if the start point in a range() is a function call or even if it is modified to a new value inside the loop? Even if it is modified, the start would be evaluated only once, isn't it? I defined a start function and supplied it to the range() and from the output it looked like start is called once, and also the c output seems to agree with this. In this case if the start is a function call, then it doesn't have to be handled right? I am not sure if I have caught the topic right! Or am i missing something here?<br>
<br><br><div class="gmail_quote">On Wed, Mar 18, 2009 at 3:33 AM, Robert Bradshaw <span dir="ltr"><<a href="mailto:robertwb@math.washington.edu">robertwb@math.washington.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mar 17, 2009, at 2:35 PM, Greg Ewing wrote:<br>
<br>
> Dag Sverre Seljebotn wrote:<br>
><br>
>> ForFromStatNode is used in two situations in Cython code; in the<br>
>> Cython-specific syntax<br>
>><br>
>> cdef int i<br>
>> for i from start <= i < end [by step]:<br>
>> ...<br>
>><br>
>> In the former case, end should NOT be frozen (i.e. if it is a<br>
>> function<br>
>> call it should be called again for every iteration<br>
><br>
> Has Cython changed this? It's not how the for-from<br>
> statement works in Pyrex -- the limits are only<br>
> evaluated once.<br>
<br>
</div>No, Cython has not changed this, and I'm not sure we should. But<br>
there is some inconsistency:<br>
<br>
%cython<br>
cdef int get_bound(int m):<br>
print "get_bound(%s)"%m<br>
return m<br>
<br>
def test_var(int n, int m):<br>
cdef int i<br>
for i from 0 <= i < n:<br>
print "at", i<br>
n = m<br>
return i<br>
<br>
def test_func(int n):<br>
cdef int i<br>
for i from 0 <= i < get_bound(n):<br>
print "at", i<br>
return i<br>
<br>
sage: test_var(10, 5)<br>
at 0<br>
at 1<br>
at 2<br>
at 3<br>
at 4<br>
5<br>
sage: test_func(5)<br>
get_bound(5)<br>
at 0<br>
at 1<br>
at 2<br>
at 3<br>
at 4<br>
5<br>
<font color="#888888"><br>
- Robert<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Cython-dev mailing list<br>
<a href="mailto:Cython-dev@codespeak.net">Cython-dev@codespeak.net</a><br>
<a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Anoop S.<br><br>People who says, "It's not winning or losing that matters, but participation", probably lost.<br>