[Python-Dev] Please reconsider PEP 479.

Greg greg.ewing at canterbury.ac.nz
Wed Nov 26 01:58:25 CET 2014


I'm not particularly opposed to PEP 479, but the Abstract and
Rationale could do with considerable clarification. They currently
appear to promise things that are in disagreement with what the PEP
actually delivers.

The Abstract claims that the proposal will "unify the behaviour of
list comprehensions and generator expressions", but it doesn't do
that. What it actually does is provide special protection against
escaped StopIteration exceptions in one particular context (the
body of a generator). It doesn't prevent StopIteration from
escaping anywhere else, including from list comprehensions, so if
anything it actually *increases* the difference between generators
and comprehensions.

There may be merit in preventing rogue StopIterations escaping
from generators, but the PEP should sell the idea on that basis, not
on what sounds like a false promise that it will make comprehensions
and generators behave identically.

-- 
Greg



More information about the Python-Dev mailing list