How to get memory size/usage of python object

Sion Arrowsmith siona at chiark.greenend.org.uk
Wed Jan 9 12:16:21 EST 2008


Santiago  Romero  <sromero at gmail.com> 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 chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "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