[Python-ideas] "Iteration stopping" syntax [Was: Is this PEP-able? for X in ListY while conditionZ:]

Nick Coghlan ncoghlan at gmail.com
Sun Jun 30 13:32:08 CEST 2013


On 30 June 2013 17:26, Andrew Barnert <abarnert at yahoo.com> wrote:
> If we removed that one difference, it would be even simpler. I don't think the difference buys us anything, and the cost of eliminating it is a relatively simple patch with minimal performance impact. (As a minor side benefit, that would also mean you could use the StopIteration hack in comps, but I still don't think we'd want to recommend doing that.)

An interesting rationale, especially along with your reply to Ron
about how much simpler that approach is than attempting to optimize
list(genexp), while still yielding a semantically equivalent end
result.

It still raises my "behavioural change without adequate justification"
hackles, but I'm only -0 now, whereas I was definitely -1 earlier.
It's definitely a much smaller change than the scoping one we
introduced in the Python 3 migration, which had the dual motivation of
moving the iteration variable into a private scope, and better
aligning the other semantics of "[x for x in y]" vs "list(x for x in
y)".

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list