@@ -29,7 +29,7 @@ static Py_ssize_t hashstats[Py_HASH_STATS_MAX + 1] = {0};
2929#endif
3030
3131/* For numeric types, the hash of a number x is based on the reduction
32- of x modulo the prime P = 2**_PyHASH_BITS - 1. It's designed so that
32+ of x modulo the prime P = 2**PyHASH_BITS - 1. It's designed so that
3333 hash(x) == hash(y) whenever x and y are numerically equal, even if
3434 x and y have different types.
3535
@@ -52,8 +52,8 @@ static Py_ssize_t hashstats[Py_HASH_STATS_MAX + 1] = {0};
5252
5353 If the result of the reduction is infinity (this is impossible for
5454 integers, floats and Decimals) then use the predefined hash value
55- _PyHASH_INF for x >= 0, or -_PyHASH_INF for x < 0, instead.
56- _PyHASH_INF and -_PyHASH_INF are also used for the
55+ PyHASH_INF for x >= 0, or -PyHASH_INF for x < 0, instead.
56+ PyHASH_INF and -PyHASH_INF are also used for the
5757 hashes of float and Decimal infinities.
5858
5959 NaNs hash with a pointer hash. Having distinct hash values prevents
@@ -65,16 +65,16 @@ static Py_ssize_t hashstats[Py_HASH_STATS_MAX + 1] = {0};
6565 efficiently, even if the exponent of the binary or decimal number
6666 is large. The key point is that
6767
68- reduce(x * y) == reduce(x) * reduce(y) (modulo _PyHASH_MODULUS )
68+ reduce(x * y) == reduce(x) * reduce(y) (modulo PyHASH_MODULUS )
6969
7070 provided that {reduce(x), reduce(y)} != {0, infinity}. The reduction of a
7171 binary or decimal float is never infinity, since the denominator is a power
7272 of 2 (for binary) or a divisor of a power of 10 (for decimal). So we have,
7373 for nonnegative x,
7474
75- reduce(x * 2**e) == reduce(x) * reduce(2**e) % _PyHASH_MODULUS
75+ reduce(x * 2**e) == reduce(x) * reduce(2**e) % PyHASH_MODULUS
7676
77- reduce(x * 10**e) == reduce(x) * reduce(10**e) % _PyHASH_MODULUS
77+ reduce(x * 10**e) == reduce(x) * reduce(10**e) % PyHASH_MODULUS
7878
7979 and reduce(10**e) can be computed efficiently by the usual modular
8080 exponentiation algorithm. For reduce(2**e) it's even better: since
@@ -92,7 +92,7 @@ _Py_HashDouble(PyObject *inst, double v)
9292
9393 if (!isfinite (v )) {
9494 if (isinf (v ))
95- return v > 0 ? _PyHASH_INF : - _PyHASH_INF ;
95+ return v > 0 ? PyHASH_INF : - PyHASH_INF ;
9696 else
9797 return PyObject_GenericHash (inst );
9898 }
@@ -109,19 +109,19 @@ _Py_HashDouble(PyObject *inst, double v)
109109 and hexadecimal floating point. */
110110 x = 0 ;
111111 while (m ) {
112- x = ((x << 28 ) & _PyHASH_MODULUS ) | x >> (_PyHASH_BITS - 28 );
112+ x = ((x << 28 ) & PyHASH_MODULUS ) | x >> (PyHASH_BITS - 28 );
113113 m *= 268435456.0 ; /* 2**28 */
114114 e -= 28 ;
115115 y = (Py_uhash_t )m ; /* pull out integer part */
116116 m -= y ;
117117 x += y ;
118- if (x >= _PyHASH_MODULUS )
119- x -= _PyHASH_MODULUS ;
118+ if (x >= PyHASH_MODULUS )
119+ x -= PyHASH_MODULUS ;
120120 }
121121
122- /* adjust for the exponent; first reduce it modulo _PyHASH_BITS */
123- e = e >= 0 ? e % _PyHASH_BITS : _PyHASH_BITS - 1 - ((-1 - e ) % _PyHASH_BITS );
124- x = ((x << e ) & _PyHASH_MODULUS ) | x >> (_PyHASH_BITS - e );
122+ /* adjust for the exponent; first reduce it modulo PyHASH_BITS */
123+ e = e >= 0 ? e % PyHASH_BITS : PyHASH_BITS - 1 - ((-1 - e ) % PyHASH_BITS );
124+ x = ((x << e ) & PyHASH_MODULUS ) | x >> (PyHASH_BITS - e );
125125
126126 x = x * sign ;
127127 if (x == (Py_uhash_t )- 1 )
0 commit comments