[Python-Dev] accumulator display syntax

Neil Schemenauer nas-python at python.ca
Wed Oct 22 11:08:16 EDT 2003


On Wed, Oct 22, 2003 at 01:19:58AM -0400, Raymond Hettinger wrote:
>     Experience with list expressions has shown their wide-spread
>     utility throughout Python.  However, many of the use cases do
>     not need to have a full list created in memory.  Instead, they
>     only need to iterate over the elements one at a time.

I see generator expression as making available the iterator guts of
list comprehensions available as a first class object.  The list()
call is not always wanted.

>     1) In order to achieve a performance gain, generator expressions need
>     to be run in the local stackframe
[...]
>     Accordingly, the generator expression cannot be returned
>     to another function:

That would be unacceptable, IMHO.  Generator expressions should be
first class.  Luckily, generator functions are speedy little buggers. :-)

  Neil



More information about the Python-Dev mailing list