[Python-Dev] dict and required hashing
Victor Stinner
victor.stinner at gmail.com
Sat Apr 19 05:05:15 CEST 2014
Does it mean that depending of the number of items, keys can be mutable? It
sounds like a terrible idea.
Victor
Le vendredi 18 avril 2014, Jim J. Jewett <jimjjewett at gmail.com> a écrit :
> (1) I believe the recent consensus was that the number of comparisons
> made in a dict lookup is an implementation detail. (Please correct me
> if I am wrong.)
>
> (2) Is "the item will be hashed at least once" a language guarantee?
>
> For small mappings, it might well be more efficient to just store the
> 2-3 key/value pairs and skip the bucket calculation.
>
> On the other hand, if a key is not hashable, discovering that long
> after it has already been added to the dict is suboptimal.
>
> Of course, that sort of delayed exception can already happen if it is
> the __eq__ method that is messed up ...
>
> -jJ
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org <javascript:;>
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140418/6e9cb4ac/attachment.html>
More information about the Python-Dev
mailing list