[Python-Dev] List comprehensions
Paul Prescod
paul@prescod.net
Thu, 13 Jul 2000 12:51:04 -0500
"M.-A. Lemburg" wrote:
>
> If it means writing code in square brackets: yes --
> I don't see any real benefit other than confusing the reader...
> it doesn't even gain any performance
We've discussed making them lazy, which would improve performance in
some cases...especially with infinite lists. :)
> Oh, so I won't get these with list comprehension ? Hmm, then
> I'm posting on the wrong thread, I guess ;-)
Well, I didn't want to say it, but...
> Say, wouldn't it make more sense to
> have these notations generate tuples (which are immutable and
> could thus be stored as constants) rather than lists ?!
I think that the notation should create a generator.
> The for-loop opcode could even make some use of this by not generating
> a tuple at all (it could use a special mutable counter like the
> one available in my speedup patch for 1.5:
We discussed this yesterday. Anyhow, you don't need to use tuples to get
the speedup. You just have to recognize the pattern in a peephole
optimizer.
--
Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it.
- http://www.cs.yale.edu/~perlis-alan/quotes.html