PEP 289: Generator Expressions - Accepted for Py2.4
started 11/5/2003; 2:30:24 PM - last post 11/11/2003; 8:33:30 AM
|
|
Ehud Lamm - PEP 289: Generator Expressions - Accepted for Py2.4
11/5/2003; 2:30:24 PM (reads: 5251, responses: 3)
|
|
PEP 289: Generator Expressions - Accepted for Py2.4 |
Experience with list comprehensions 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...
Generator expressions are especially useful with functions like sum(), min(), and max() that reduce an iterable input to a single value.
Surely a step in the right direction, though I suspect Haskell mavens will find this document a bit amusing, especially as regards Python's struglling with scope and the fact that the word 'lazy' doesn't appear anywhere in this document.
I guess the only real conclusion we can draw from this PEP is that Python programmers love catamorphisms...
Posted to Python by Ehud Lamm on 11/5/03; 2:33:39 PM
|
|
|
|
Ehud Lamm - Re: PEP 289: Generator Expressions - Accepted for Py2.4
11/7/2003; 12:49:58 PM (reads: 239, responses: 0)
|
|
|
Chris Rathman - Re: PEP 289: Generator Expressions - Accepted for Py2.4
11/7/2003; 1:07:19 PM (reads: 238, responses: 0)
|
|
Well, if you don't change a language, people will moan. Then again, if you do change the language, people will groan. :-)
Methinks that the Icon mechanism for generators seems more natural than about any other that I've encountered.
|
|
Ehud Lamm - Re: PEP 289: Generator Expressions - Accepted for Py2.4
11/11/2003; 8:33:30 AM (reads: 185, responses: 0)
|
|
Icon's generators are very well integrated with the language's goal directed evaluation strrategy and backtracking facilities, which is why they feel so natural. Indeed, Icon without generators feels strange, since built in functions produce chains of values, and while user code cannot. Using Icon built ins you ultimately start wondering "Can I write a procedure that does this?" leading you right away to generators.
|
|
|
|