Message 101581 - Python tracker (original) (raw)
Another update, partly to address comments raised by Guido on Rietveld. I'll upload these changes to Rietveld later today.
rename sys._hash_info to sys.hash_info and make it public rather than private (it still needs docs somewhere)
add some explanatory comments to long_hash; remove an outdated comment
fix missing error check (in previous patch) in slot_tp_hash. slot_tp_hash also now always raises a TypeError if hash returns a non-integer; this is a change from current behaviour, which allows small floats to be returned by hash, but not large floats (where large means > 231 or > 263 in absolute value, depending on the system). I'm assuming this was unintentional (the docs specify that hash should return an integer).
simplify specification of hash function slightly: for nonnegative x it simply computes the reduction of x; previously it computed 1 + reduction of (x-1) for positive values. This extra +-1 doesn't really add anything of value, and makes it slightly more complicated and error-prone to write your own hash function.