[Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward

Greg Ewing greg at cosc.canterbury.ac.nz
Sun May 2 23:03:11 EDT 2004


Armin Rigo <arigo at tunes.org>:

> Early binding is closer to the idea that turning a listcomp into a
> genexprs should just work if you only iterate once on the result.

I'm not sure that's an idea we should be promulgating in the first
place. The original motivation for generator expressions was things
like

  total = sum(x**2 for x in stuff)

where not only will the sequence be used just once, but it will be
used *immediately* before doing anything else.

Those are the use cases we need to advertise this as targeting, I
think, not "any listcomp that's only used once".

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-Dev mailing list