[Python-Dev] PEP 289 - Generator Expressions (original) (raw)
[Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward
Armin Rigo arigo at tunes.org
Mon May 3 12:27:50 EDT 2004
- Previous message: [Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward
- Next message: [Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Greg,
On Mon, May 03, 2004 at 03:03:11PM +1200, Greg Ewing wrote:
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.
I understand perfecty well that anything else is advanced stuff, and that
people shouldn't do advanced stuff if they are not aware of all the issues.
I also know that any kind of laziness together with mutating objects creates
delicate problems. What I am looking for is a genexpr implementation that
would, as a bonus, be useful in advanced cases too instead of being just
unusable beyond these 95% of cases where the binding model doesn't matter.
The problem I have with late-bound names is that small, semi-advanced, "innocent enough" examples like Samuele's keep popping up that would just give wrong answers (not just crash). Personally when I look at all these examples I think they are elegant ways to express things that I could want to do, and I could easily read and write this kind of code -- but it just doesn't do that I expect it to. The real answer is much more convoluted.
The only advantage I see to late binding is that they prevent people from doing any advanced stuff with genexprs, and thus beginners never have to read code containing advanced uses of genexprs (even clean-looking one like Samuele's).
Armin
- Previous message: [Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward
- Next message: [Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]