Hash stability

Roy Smith roy at panix.com
Sat Jan 14 21:26:27 EST 2012


In article <4f1107b7$0$29988$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> On the Python Dev mailing list, there is a discussion going on about the 
> stability of the hash function for strings.
> 
> How many people rely on hash(some_string) being stable across Python 
> versions? Does anyone have code that will be broken if the string hashing 
> algorithm changes?

I would never rely on something like that unless the docs unambiguously 
stated it were so.  Which they don't.  All I can find about hash() is:

"Return the hash value of the object (if it has one). Hash values are 
integers. They are used to quickly compare dictionary keys during a 
dictionary lookup. Numeric values that compare equal have the same hash 
value (even if they are of different types, as is the case for 1 and 
1.0)."



More information about the Python-list mailing list