Skip to content

Commit 1edec34

Browse files
committed
pythongh-111389: restoring _PyHASH_INF/BITS/MODULUS/IMAG macroses as public
1 parent 74f0772 commit 1edec34

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Include/internal/pycore_pyhash.h

-17
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@ extern Py_hash_t _Py_HashPointerRaw(const void*);
1717
// Export for '_datetime' shared extension
1818
PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t);
1919

20-
/* Prime multiplier used in string and various other hashes. */
21-
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */
22-
23-
/* Parameters used for the numeric hash implementation. See notes for
24-
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
25-
reduction modulo the prime 2**_PyHASH_BITS - 1. */
26-
27-
#if SIZEOF_VOID_P >= 8
28-
# define _PyHASH_BITS 61
29-
#else
30-
# define _PyHASH_BITS 31
31-
#endif
32-
33-
#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
34-
#define _PyHASH_INF 314159
35-
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
36-
3720
/* Hash secret
3821
*
3922
* memory layout on 64 bit systems

Include/pyhash.h

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ typedef struct {
1616
PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
1717
#endif
1818

19+
/* Prime multiplier used in string and various other hashes. */
20+
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */
21+
22+
/* Parameters used for the numeric hash implementation. See notes for
23+
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
24+
reduction modulo the prime 2**_PyHASH_BITS - 1. */
25+
26+
#if SIZEOF_VOID_P >= 8
27+
# define _PyHASH_BITS 61
28+
#else
29+
# define _PyHASH_BITS 31
30+
#endif
31+
32+
#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
33+
#define _PyHASH_INF 314159
34+
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
1935

2036
/* Cutoff for small string DJBX33A optimization in range [1, cutoff).
2137
*

0 commit comments

Comments
 (0)