Performance of lists vs. list comprehensions
Dave Angel
davea at ieee.org
Wed Jan 20 06:05:50 EST 2010
Steven D'Aprano wrote:
> A million items is not a lot of data. Depending on the size of each
> object, that might be as little as 4 MB of data:
>
>
>>>> L = ['' for _ in xrange(10**6)]
>>>> sys.getsizeof(L)
>>>>
> 4348732
>
> <snip>
Note that this sys.getsizeof() is only saying the size of the list, not
the size of the objects referenced in the list. So that number doesn't
depend on "the size of the object."
DaveA
More information about the Python-list
mailing list