Generator expressions v/s list comprehensions
Peter Hansen
peter at engcorp.com
Mon Aug 30 08:50:04 EDT 2004
A small correction:
Martin DeMello wrote:
> Here's a simple example
>
> linecount = sum(1 for line in file)
> linecount = sum([1 for line in file])
>
> The former requires an in-memory list equal to the size of the file.
^^^^^^
I think you meant "the latter"...
> Consigning "other than memory consumption" to a parenthetical remark
> misses its importance.
-Peter
More information about the Python-list
mailing list