On Feb 7, 2009, at 6:56 PM, Robert Bradshaw wrote: > On Jan 30, 2009, at 11:44 AM, Stefan Behnel wrote: > >> Hi, >> >> Dag Sverre Seljebotn wrote: >>> Magnus Lie Hetland wrote: >>>> For the for-from loop, this may be intended -- as you say, it >>>> mimics >>>> the C behavior (although it seems to fly in the face of "Python >>>> intuition"): Even with the existing Cython semantics, getstep() >>>> will >>>> be called after *every iteration*. >>>> >>>> It seems to me that in >>>> >>>> for 0 <= i < n by getstep(): pass >>>> >>>> one would expect (in Python) that the step expression be evaluated >>>> only once. If that is not the case, fine. Then the for-from loop >>>> can >>>> safely be left alone as it is. >>>> >>> I think so -- the for-from loop is a C idiom from which one can >>> expect C >>> behaviour from my perspective, and if this has been the behaviour >>> so far >>> then backward compatability alone speaks against altering it. The >>> range >>> optimization has been around for much shorter and clearly should >>> behave >>> as Python range, so that story is different.
I just realized, however, that we are not following Python semantics for the empty loop: sage: i = "foo" sage: for i in range(10, 0): pass sage: print i foo - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
