Hash stability

Stefan Behnel stefan_ml at behnel.de
Sun Jan 15 05:13:56 EST 2012


Heiko Wundram, 14.01.2012 23:45:
> Am 14.01.2012 10:46, schrieb Peter Otten:
>> Steven D'Aprano wrote:
>>> 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?
>>
>> Nobody who understands the question ;)
> 
> Erm, not exactly true. There are actually some packages out there (take
> suds [https://fedorahosted.org/suds/], for example) that rely on the
> hashing algorithm to be stable to function "properly" (suds uses hash() of
> strings to create caches of objects/XML Schemas on the filesystem).

That's a stupid design. Using a hash function that the application does not
control to index into persistent storage just screams for getting the code
broken at some point.

Stefan




More information about the Python-list mailing list