Better dict of dicts

Adam Atlas adam at
Thu Apr 19 23:29:41 CEST 2007

On Apr 19, 5:24 pm, Bill Jackson <jack... at> wrote:
> I have a dictionary of dictionaries where the keys are typically very
> long tuples and repeated in each inner dictionary.  The dictionary
> representation is nice because it handles sparseness well...and it is
> nice to be able to look up values based on a string rather than a
> number.  However, since my keys are quite long, I worry that I am
> wasting a lot of memory.

I wouldn't worry about it. Try doing hash('string_2') in the
interpreter -- the output thereof is what's really being used as the
key. It doesn't use up any more memory than the integer 2.

More information about the Python-list mailing list