On Wed, Apr 20, 2022 at 7:23 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Maybe hashes should point to an object rather than being the hash of an
> object themselves.
> Maybe the speed drop is not worth it.
>

If you need mutable keys, you /might/ create a dict-like-object using what
functional languages call an association list.  But these have O(n)
lookups, not O(1) like a dict (AKA hash table).  And even then, if you have
keys a and b, a != b, and you modify b to look just like a, you could get a
bit of a mess from the two equal keys mapping to two different values.

It is possible to have a dict that allows duplicates though.  Usually
that's not what you want, but sometimes it is, EG:
https://stromberg.dnsalias.org/~strombrg/dupdict_mod/

Trees have much the same issue as a dict (hash table) in this case.  These
are O(logn) or so.

The problem is hash tables and trees don't want keys changing "out from
under them".  It causes things they're assuming are invariant, to vary.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to