At 08:57 AM 10/21/03 -0500, Skip Montanaro wrote: > >> [Alex measures speed improvements] > > Guido> Great! This is a plus for iterator comprehensions (we need a > Guido> better term BTW). > >Here's an alternate suggestion. Instead of inventing new syntax, why not >change the semantics of list comprehensions to be lazy? They haven't been >in use that long, and while they are popular, the semantic tweakage would >probably cause minimal disruption. In situations where laziness wasn't >wanted, the most that a particular use would have to change (I think) is to >pass it to list(). If you make it a list that's lazy, it doesn't lose the memory allocation overhead for the list. If I understand Alex's benchmarks, making a lazy list would end up being *slower* than list comprehension is now. I previously proposed a different solution earlier in this thread, where you get a pseudo-list that, if iterated, runs the underlying generator function. But there were issues with possible side-effects (not to mention reiterability) of the underlying iterator on which the comprehension was based.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4