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). Since list comprehensions are planned to just be syntactic sugar for generator comprehension, generator comprehensions are now the more fundamental construct. But yeah, it is a little awkward, since something that is sorted can be returned as a list anyway, except for the fact that the expression itself could be ported off elsewhere which isn't normal Python. (But should be normal Python!) -- Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
