[Cython] can we deprecate for-from loops?
robertwb at gmail.com
Mon Oct 12 11:37:18 EDT 2015
On Sun, Oct 11, 2015 at 3:31 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Stefan Behnel wrote:
>> The syntax construct "for i from 0 <= i < 10" has been silently outdated
>> for years. Can we start issuing a warning that normal range() loops are
> I'd be in favour of replacing it with just 'for 0 <= i < 10',
> but -1 on removing it altogether.
> I introduced it in Pyrex for a reason -- to clearly express
> iterations over ranges of integers with arbitrary combinations
> of open/closed endpoints,
I agree that it expresses intent clearer than the range(...) construct.
> for use in conjunction with C code.
> I believe that reason is still valid.
I'm not sure why "in conjunction with C code" makes any difference to
the argument, now that the basic range loop produces the same code in
Cython. Put another way, does its clarity merit a PEP to introduce
this syntax into Python? If not, it's hard to justify in Cython given
that it is a fully redundant addition to the language.
More information about the cython-devel