Estimating size of dictionary

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Nov 24 00:55:48 EST 2008


On Sun, 23 Nov 2008 21:10:34 -0500, python wrote:

> Is there a formula for determining the approximate size of a dictionary
> (minus its data) under 32 and 64 bit Python with a specific average key
> size?

If you're using Python 2.6, the sys module has a new function getsizeof() 
which returns the number of bytes used by an object.

You can also look at this recipe:

http://code.activestate.com/recipes/546530/

This question has been asked before. See:

http://mail.python.org/pipermail/python-list/2008-January/472683.html
http://mail.python.org/pipermail/python-list/2002-March/135223.html

and probably others.



-- 
Steven



More information about the Python-list mailing list