How to get memory size/usage of python object

Sion Arrowsmith siona at
Wed Jan 9 18:16:21 CET 2008

Santiago  Romero  <sromero at> wrote:
> Is there a way to check the REAL size in memory of a python object?
> Something like
>> print sizeof(mylist)
> [ ... ]

Would you care to precisely define "REAL size" first? Consider:

>>> atuple = (1, 2)
>>> mylist = [(0, 0), atuple]

Should sizeof(mylist) include sizeof(atuple) ?

>>> del atuple

What about now, when mylist has the only reference to the (1, 2)
object that also used to be referred to as atuple?

\S -- siona at --
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump

More information about the Python-list mailing list