On May 13, 2008, at 5:15 AM, Stefan Behnel wrote:
> Hi Greg,
>
> Greg Ewing wrote:
>>> 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.
>
> Not redundant, no. But less calling for improvement.
>
>
>> The 'for i from...' version was a compromise
>
> I understand that. Still, having two spellings for "for ...
> in ...", one
> for Python, one for C, looks better than a completely different syntax
> that just starts with "for". So I vote for
>
> for x in iterable:
>
> and
>
> for x in 1 < x <= 5:
>
> instead of the new
>
> for 1 < x <= 5:
>
> purely for readability (and obviously keeping the old "from"
> spelling for
> compatibility).
I'm -1 for having lots of multiple ways to do for loops (including
that list of PEPs--we're already up to 3). Also, "from" makes it
clear that this is a special cython loop--consider the following:
x = 1
class A:
def __gt__(self, other):
return range(3,7)
for x in 0 <= x < A():
print x
This is valid Python (prints 3, 4, 5, 6), and would act completely
differently under your proposal.
I do think optimizing enumerate/zip/etc is feasible and probably
worthwhile.
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev