List size versus list allocation
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun May 2 19:26:46 EDT 2010
On Sun, 02 May 2010 18:07:31 +0200, Christian Heimes wrote:
>> I'm interested in gathering some statistics on this, and to do so I
>> need a way of measuring the list's logical size versus its actual size.
>> The first is easy: it's just len(list). Is there some way of getting
>> the allocated size of the list?
>
> With Python 2.6 and newer you can use sys.getsizeof() to get the actual
> size of the list object:
Thanks Christian and Peter for your answers. That's very helpful.
--
Steven
More information about the Python-list
mailing list