[Python-3000] Adding sorting to generator comprehension
Josiah Carlson
jcarlson at uci.edu
Mon Apr 24 20:55:20 CEST 2006
Ian Bicking <ianb at colorstudy.com> wrote:
>
> Josiah Carlson wrote:
> > One of the features of generator expressions which makes it desireable
> > instead of list comprehensions is that generator expressions may use
> > less memory *now*, and may be able to start returning results *now*.
> >
> > Using (<genexp> orderby ...) as a replacement for sorted((genexp), key=...)
> > is a bit misleading because while the original generator expression
> > could have been space and time efficient, the orderby version certainly may
> > not be.
>
> Certainly it changes the performance substantially (of course if the
> expression is translated and executed elsewhere the performance can
> actually be improved, so it can go both ways).
I think that discussions over farming out sorted(genexp) computation is
a little premature, and I would hope that such would be explicit in any
case.
- Josiah
More information about the Python-3000
mailing list