generator expressions: performance anomaly?

Diez B. Roggisch deetsNOSPAM at web.de
Tue Jan 18 07:49:06 EST 2005


> Something else I was thinking about. I think it would be nice if the
> python compilor could figure out whether a genexp in a list or tuple
> expression always generates the same list or tuple and then instead
> of generating code would generate the list or tuple in place.

This won't ever happen in python - at least not in python otherwise similar
to the one we know...

The thing you're after is known as "common subexpression elemination" and
can only be done in purely functional languages. While that certainly is an
interesting property of a language, it e.g. forbids functions like
time.time() - a too huge paradigm shift for python.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list