Generator expressions vs. comprehensions

Terry Reedy tjreedy at udel.edu
Tue May 25 13:09:23 EDT 2010


On 5/25/2010 3:08 AM, Peter Otten wrote:
> Michele Simionato wrote:

> I think not turning the list-comp into syntactic sugar for list(genexp) in
> py3 is a missed opportunity.

Implementing it that way was tried but was much slower than the current 
implementation. If one uses StopIteration as it is intended to be used 
(and is so documented), then, I believe, they are equivalent. There was 
a conscious decision to not slow comprehensions for the many to cater to 
the very few.

Terry Jan Reedy




More information about the Python-list mailing list