A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-April/134175.html below:

[Python-Dev] dict and required hashing

[Python-Dev] dict and required hashing [Python-Dev] dict and required hashingArmin Rigo arigo at tunes.org
Sat Apr 19 10:43:44 CEST 2014
Hi Jim,

On 18 April 2014 23:46, Jim J. Jewett <jimjjewett at gmail.com> wrote:
> (2)  Is "the item will be hashed at least once" a language guarantee?

I think that a reasonable implementation needs to hash at least once
all keys that are added to the dictionary.  Otherwise we end up, as
you said, with a dictionary that contains non-hashable keys: this
crashes when it grows and tries to convert from a list storage to a
hash table.  This is against the expectations and probably against the
language spec...

It's a bit unclear to me if the language spec requires "if [ ] in
mydict:" to raise TypeError, as the key doesn't get added to the dict
in this case.  Similarly for "[ ] in { }" where the dictionary is
empty anyway.  I would say yes, erring on the side of caution...


A bientôt,

Armin.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4