PEP 289: Generator Expressions (please comment)
Peter Hansen
peter at engcorp.com
Thu Oct 23 16:58:18 EDT 2003
More information about the Python-list mailing list
Thu Oct 23 16:58:18 EDT 2003
- Previous message (by thread): PEP 289: Generator Expressions (please comment)
- Next message (by thread): PEP 289: Generator Expressions (please comment)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Daniel Dittmar wrote: > > Raymond Hettinger wrote: > > bestplayer, bestscore = max( (p.score, p.name) for p in players ) > > > > Each of the above runs without creating a full list in memory, > > which saves allocation time, conserves resources, and exploits > > cache locality. > > Why should generator comprehension be useful only for arguments? > > counter proposal: > g[(p.score, p.name) for p in players ] > > This works similar to r'\' for raw strings and u'x' for unicode strings. Except that r'' can mean nothing else, syntactically, while g[something] could be a dictionary lookup using <something> as the key.
- Previous message (by thread): PEP 289: Generator Expressions (please comment)
- Next message (by thread): PEP 289: Generator Expressions (please comment)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list