Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move to Include/cpython/pyhash.h
  • Loading branch information
skirpichev committed Nov 16, 2023
commit a8dec64eb606d0e980cf55410ea09da0f4ad19f5
5 changes: 5 additions & 0 deletions Include/cpython/pyhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
# define _PyHASH_BITS 31
#endif

#define PyHASH_BITS _PyHASH_BITS
Comment thread
skirpichev marked this conversation as resolved.
Outdated

#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
#define PyHASH_MODULUS _PyHASH_MODULUS
#define _PyHASH_INF 314159
#define PyHASH_INF _PyHASH_INF
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
#define PyHASH_IMAG _PyHASH_IMAG

/* Helpers for hash functions */
PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double);
Expand Down
22 changes: 0 additions & 22 deletions Include/pyhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,6 @@
extern "C" {
#endif

/* Prime multiplier used in string and various other hashes. */
#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */

/* Parameters used for the numeric hash implementation. See notes for
_Py_HashDouble in Python/pyhash.c. Numeric hashes are based on
reduction modulo the prime 2**_PyHASH_BITS - 1. */

#if SIZEOF_VOID_P >= 8
# define _PyHASH_BITS 61
#else
# define _PyHASH_BITS 31
#endif

#define PyHASH_BITS _PyHASH_BITS

#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
#define PyHASH_MODULUS _PyHASH_MODULUS
#define _PyHASH_INF 314159
#define PyHASH_INF _PyHASH_INF
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
#define PyHASH_IMAG _PyHASH_IMAG

/* Cutoff for small string DJBX33A optimization in range [1, cutoff).
*
* About 50% of the strings in a typical Python application are smaller than
Expand Down