[Python-Dev] Hashing proposal: change only string-only dicts (original) (raw)

Victor Stinner victor.stinner at haypocalc.com
Tue Jan 17 23:57:46 CET 2012


Each string would get two hashes: the "public" hash, which is constant across runs and bugfix releases, and the dict-hash, which is only used by the dictionary implementation, and only if all keys to the dict are strings.

The distinction between secret (private, secure) and "public" hash (deterministic) is not clear to me.

Example: collections.UserDict implements hash() using hash(self.data). Should it use the public or the private hash? collections.abc.Set computes its hash using hash(x) of each item. Same question.

If we need to use the secret hash, it should be exposed in Python. Which function/method would be used? I suppose that we cannot add anything to stable releases like 2.7.

Victor



More information about the Python-Dev mailing list