[Cython] [Fwd: Re: Beginner-friendly tickets]
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Mon Mar 23 09:10:20 CET 2009
Prajwal Suhas P wrote:
> The old patch i supplied works perfectly fine for cases--->
> >for i in range(0, 10, somefunc( )):--->STEP case and
> >for i in range(0, somefunc( ) , 1):---->Loop Bound case
>
> but it doesn't work as expected when we invoke a function in start of
> loop as like, for i in range(somefunc( ), 10, 1):.
Ah right; that problem was introduced when the wrapping if-test was
added so that empty loops doesn't assign to "i" (as both the if-test and
the loop checks the start-point)
Once "i" is put in a temporary as well (so that modifying "i" within the
loop doesn't affect looping) this should not be necesarry as the
startpoint will only be called once. So I'd recommend that strategy
instead of this patch; it should be done anyway before a release. For
that reason I'm -1 on applying this.
(Then one would go back to the old behaviour with for-from I suppose,
i.e. so that "for i from 10 <= i < 7: pass" would assign 10 to i).
BTW one should ideally test with negative steps as well, though I expect
the result to be the same. I.e. "for i in range(10, somefunc(), -1)" and
so on.
--
Dag Sverre
More information about the Cython-dev
mailing list