Memory sizes of python objects?

Clark C . Evans cce at clarkevans.com
Sat Mar 23 23:43:22 CET 2002


Hello.  I'm trying to figure out how much memory overhead
is used with using strings, tuples, lists, and maps.
In particular, say I have a nested structure like...

entry = (92939938,"This is one of thousands of map entries",
         """ 
             It even has multi-line data in it, appx 400
             characters per entry.
         ""","2002-31-02 12:20 +500","Dogmeat")
dict = {"Dogmeat":entry,
        # about a thousand more "indexed" entries
       }
lst  = [ entry,
       # about a thousand more entries
       ]

etc.  Is there some rule of thumb that I can use to estimate,
for example, take the character data you have and multiply by
a factor of 4 to find the in-memory footprint of tuples, and
each map is 1K plus 64 bytes per entry..

Best,

Clark




More information about the Python-list mailing list