[Pyrex] [Cython] Language stability

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 13 02:17:55 CEST 2008


Stefan Behnel wrote:
> The latest syntax change regarding the
> for loop is not required for Cython

Concerning that, I've decided to remove the deprecation
warning, and continue supporting the old syntax. This will
be done in the next release; in the meantime, you can
apply the following patch:

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/undeprecate-for-from.patch

> where the (IMHO much more obvious) cdef +
> range() syntax is optimised

Even in the presence of this optimisation, I don't consider
that the integer for-loop syntax is entirely redundant.

It concisely and clearly expresses all the possible combinations
of including or excluding the lower and upper bound, together
with iteration direction. This is something that I don't think
is obvious at all with range() once you get beyond the simplest
cases.

It's for this reason -- notational clarity -- that I
introduced the integer for-loop syntax, at least as much as
optimisation.

This is also the reason I want to simplify the syntax. The
'for i from...' version was a compromise -- I was originally
thinking of it as a possible addition to Python itself, and
I didn't want to do anything that would cause undue difficulties
for Python's parser.

But the Pyrex parser is more flexible, and it turns out not
to be very difficult at all to do it the way I originally
envisaged.

-- 
Greg



More information about the Pyrex mailing list