I would like to map values returned by Python's hash()
function to floats in the range 0 to 1. On my system I can do this with
scale = 1.0/(2**64)
print hash(some_object)*scale+0.5
However, I know this will be different on 32-bit systems. Most likely I will never run this code anywhere else, but still I would like to know if there's a way to programmatically determine the maximum and minimum values that Python's built-in hash()
function can return.
(By the way the reason I'm doing this is that I'm developing a numerical simulation in which I need to consistently generate the same pseudo-random number from a given Numpy array. I know the built-in hash won't have the best statistics for this, but it's fast, so it's convenient to use it for testing purposes.)