Performance of lists vs. list comprehensions

Raymond Hettinger python at rcn.com
Tue Jan 19 22:54:02 CET 2010


[Wolfram Hinderer]
> Yes, list building from a generator expression *is* expensive. And
> join has to do it, because it has to iterate twice over the iterable
> passed in: once for calculating the memory needed for the joined
> string, and once more to actually do the join (this is implementation
> dependent, of course). If the iterable is a list already, the list
> building is not needed.

Good analysis.  That is exactly what is going on under the hood.


Raymond



More information about the Python-list mailing list