Determining the range of values returned by Python's hash()

In Python 2.7 hash() returns an int, so sys.maxint should give you an idea of its range.


This is not really an answer to your main question, but an answer to your fine print. numpy RNG takes numpy arrays as seeds (hashing them internally):

>>> import numpy
>>> a = numpy.arange(1000)
>>> b = a.copy()
>>> b[-1] = 0
>>> r1 = numpy.random.RandomState(a)
>>> r2 = numpy.random.RandomState(b)
>>> r3 = numpy.random.RandomState(a)
>>> r1.rand()
0.9343370187421804
>>> r3.rand()
0.9343370187421804
>>> r2.rand()
0.4651506189783071

Tags:

Python

Hash