[Cython] Fix for #196 (for loop bug)
Magnus Lie Hetland
magnus at hetland.org
Fri Jan 30 14:11:59 CET 2009
On Jan 30, 2009, at 14:03, Magnus Lie Hetland wrote:
> for i in range(0,10,2): pass
> for j in range(0,10,getstep()): pass
>
> print i, j
> # (10, 8)
Ahm. I guess the explanation here was, in fact, quite obvious from the
fact that the code was too hairy for me to see the bug: Unless I'm
mistaken, the version with the function call isn't optimized and
hence, its behavior is in line with Python semantics.
Then again, if getstep is cdef-ed to return an int, why *isn't* this
optimized to a for-from-loop? (And if it should be, the local variable
issue that Dag Sverre mentioned is again relevant.)
--
Magnus Lie Hetland
http://hetland.org
More information about the Cython-dev
mailing list