GUI Frames and classmethod

Scott David Daniels Scott.Daniels at Acm.Org
Mon Dec 6 22:08:15 CET 2004

Zak Arntson wrote:
> On Fri, 03 Dec 2004 14:48:30 -0800, Scott David Daniels
> <> wrote:
> .... question: A dictionary of dictionaries is slower than a
> dictionary of tuples, right? Because when Python accesses a
> dictionary, it produces a hash from the key and finds that in its hash
> table. Producing a hash from a tuple is much faster than producting
> two hashes and doing two lookups. At least that's what I'm assuming.
Most likely so.  Possibly an equal amount of has work -- hash of a pair
is a function of hashes of the lelements, but fewer trips in and out of
the interpretter.  So, one less lookup, less refcount fiddling, and
fewer dispatches through the interpretter.

The real advantage is clarity: the inner dictionaries in a dict-of-dict
implementation have no real "meaning."  The extra overhead (in the mind
of the program reader) involved in creating inner dictionaries at
appropriate times makes the code harder to understand.

--Scott David Daniels
Scott.Daniels at

More information about the Python-list mailing list