Performance of lists vs. list comprehensions

Dave Angel davea at
Wed Jan 20 12:05:50 CET 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."


More information about the Python-list mailing list