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
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to