How to get memory size/usage of python object

Santiago Romero sromero at gmail.com
Thu Jan 10 03:14:42 EST 2008


> Would you care to precisely define "REAL size" first? Consider:
>
> >>> atuple = (1, 2)
> >>> mylist = [(0, 0), atuple]
>
> Should sizeof(mylist) include sizeof(atuple) ?

 No, I'm talking about "simple" lists, without REFERENCES to another
objects into it.

 I mean:

lists = [ 0, 1, 2, 3, 4, (1,2), 3]

 or

array = [ [0,0,0,0,0,0,0], [1,1,1,1,2,1,2], ... ]

 Maybe I can "pickle" the object to disk and see the filesize ... :-?




More information about the Python-list mailing list