Estimating size of dictionary

Steven D'Aprano steven at
Mon Nov 24 06:55:48 CET 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:

This question has been asked before. See:

and probably others.


More information about the Python-list mailing list