Skip to content

Commit ca28127

Browse files
committed
pythongh-111389: Make PyHASH_MULTIPLIER constant public
1 parent 72d07dd commit ca28127

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Doc/c-api/hash.rst

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
2929

3030
.. versionadded:: 3.13
3131

32+
.. c:macro:: PyHASH_MULTIPLIER
33+
34+
Prime multiplier used in string and various other hashes.
35+
36+
.. versionadded:: 3.13
37+
3238
.. c:macro:: PyHASH_INF
3339
3440
The hash value returned for a positive infinity.

Include/cpython/pyhash.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#endif
44

55
/* Prime multiplier used in string and various other hashes. */
6-
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */
6+
#define PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */
77

88
/* Parameters used for the numeric hash implementation. See notes for
99
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
@@ -17,7 +17,7 @@
1717

1818
#define PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
1919
#define PyHASH_INF 314159
20-
#define PyHASH_IMAG _PyHASH_MULTIPLIER
20+
#define PyHASH_IMAG PyHASH_MULTIPLIER
2121

2222
/* Aliases kept for backward compatibility with Python 3.12 */
2323
#define _PyHASH_BITS PyHASH_BITS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add :c:macro:`PyHASH_MULTIPLIER` constant: prime multiplier used in string
2+
and various other hashes. Patch by Victor Stinner.

0 commit comments

Comments
 (0)