order independent hash?
88888 Dihedral
dihedral88888 at googlemail.com
Wed Dec 7 12:48:11 EST 2011
On Wednesday, December 7, 2011 9:28:40 PM UTC+8, Hrvoje Niksic wrote:
> Chris Angelico <ros... at gmail.com> writes:
>
> > 2011/12/5 Hrvoje Niksic <hni... at xemacs.org>:
> >> If a Python implementation tried to implement dict as a tree,
> >> instances of classes that define only __eq__ and __hash__ would not
> >> be correctly inserted in such a dict.
> >
> > Couldn't you just make a tree of hash values? Okay, that's probably
> > not the most useful way to do things, but technically it'd comply with
> > the spec.
>
> That's a neat idea. The leaves of the tree would contain a list of
> items with the same hash, but that's what you effectively get with a
> linear-probe hash table anyway.
>
> As you said, not immediately useful, but one could imagine the technique
> being of practical use when implementing Python or a Python-compatible
> language in a foreign environment that supports only tree-based
> collections.
The heap as the root that could be divided like a tree of nodes to be used
is funny. There are many ways to implement the heap manager in SW.
More information about the Python-list
mailing list