File tree 3 files changed +37
-6
lines changed
3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 3
3
PyHash API
4
4
----------
5
5
6
- See also the :c:member: `PyTypeObject.tp_hash ` member.
6
+ See also the :c:member: `PyTypeObject.tp_hash ` member and :ref: ` numeric-hash ` .
7
7
8
8
.. c :type :: Py_hash_t
9
9
@@ -17,6 +17,29 @@ See also the :c:member:`PyTypeObject.tp_hash` member.
17
17
18
18
.. versionadded :: 3.2
19
19
20
+ .. c :macro :: PyHASH_MODULUS
21
+
22
+ The `Mersenne prime <https://en.wikipedia.org/wiki/Mersenne_prime >`_ ``P = 2**n -1 ``, used for numeric hash scheme.
23
+
24
+ .. versionadded :: 3.13
25
+
26
+ .. c :macro :: PyHASH_BITS
27
+
28
+ The exponent ``n `` of ``P `` in :c:macro: `PyHASH_MODULUS `.
29
+
30
+ .. versionadded :: 3.13
31
+
32
+ .. c :macro :: PyHASH_INF
33
+
34
+ The hash value returned for a positive infinity.
35
+
36
+ .. versionadded :: 3.13
37
+
38
+ .. c :macro :: PyHASH_IMAG
39
+
40
+ The multiplier used for the imaginary part of a complex number.
41
+
42
+ .. versionadded :: 3.13
20
43
21
44
.. c :type :: PyHash_FuncDef
22
45
Original file line number Diff line number Diff line change 10
10
reduction modulo the prime 2**_PyHASH_BITS - 1. */
11
11
12
12
#if SIZEOF_VOID_P >= 8
13
- # define _PyHASH_BITS 61
13
+ # define PyHASH_BITS 61
14
14
#else
15
- # define _PyHASH_BITS 31
15
+ # define PyHASH_BITS 31
16
16
#endif
17
17
18
- #define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
19
- #define _PyHASH_INF 314159
20
- #define _PyHASH_IMAG _PyHASH_MULTIPLIER
18
+ #define PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
19
+ #define PyHASH_INF 314159
20
+ #define PyHASH_IMAG _PyHASH_MULTIPLIER
21
+
22
+ /* Aliases kept for backward compatibility with Python 3.12 */
23
+ #define _PyHASH_BITS PyHASH_BITS
24
+ #define _PyHASH_MODULUS PyHASH_MODULUS
25
+ #define _PyHASH_INF PyHASH_INF
26
+ #define _PyHASH_IMAG PyHASH_IMAG
21
27
22
28
/* Helpers for hash functions */
23
29
PyAPI_FUNC (Py_hash_t ) _Py_HashDouble (PyObject * , double );
Original file line number Diff line number Diff line change
1
+ Add :c:macro: `PyHASH_MODULUS `, :c:macro: `PyHASH_BITS `, :c:macro: `PyHASH_INF `
2
+ and :c:macro: `PyHASH_IMAG ` C macros. Patch by Sergey B Kirpichev.
You can’t perform that action at this time.
0 commit comments