order independent hash?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Dec 4 21:00:53 EST 2011


Dihedral, you're back to double posting. Please stop. Send to the mailing 
list, or to the newsgroup, it doesn't matter. But don't send to both.

Further comments below.


On Sun, 04 Dec 2011 16:52:14 -0800, 88888 Dihedral wrote:

> If v is a tuple or a list then a dictionary in python can replace a
> bi-directional list or a tree under the assumption that the hash which 
> accesses values stored in a  much faster way  when well implemented.

No it can't.

The keys in a hash tables are unordered. You get an order when you 
iterate over them, but that order is arbitrary.

Keys in a list or tree are ordered. E.g. collections.OrderedDict 
remembers the order that keys are added. If Python were to replace 
OrderedDicts with dicts, it would break code.


-- 
Steven



More information about the Python-list mailing list