Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:42

0001 #ifndef Py_CPYTHON_HASH_H
0002 #  error "this header file must not be included directly"
0003 #endif
0004 
0005 /* Prime multiplier used in string and various other hashes. */
0006 #define PyHASH_MULTIPLIER 1000003UL  /* 0xf4243 */
0007 
0008 /* Parameters used for the numeric hash implementation.  See notes for
0009    _Py_HashDouble in Python/pyhash.c.  Numeric hashes are based on
0010    reduction modulo the prime 2**_PyHASH_BITS - 1. */
0011 
0012 #if SIZEOF_VOID_P >= 8
0013 #  define PyHASH_BITS 61
0014 #else
0015 #  define PyHASH_BITS 31
0016 #endif
0017 
0018 #define PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
0019 #define PyHASH_INF 314159
0020 #define PyHASH_IMAG PyHASH_MULTIPLIER
0021 
0022 /* Aliases kept for backward compatibility with Python 3.12 */
0023 #define _PyHASH_MULTIPLIER PyHASH_MULTIPLIER
0024 #define _PyHASH_BITS PyHASH_BITS
0025 #define _PyHASH_MODULUS PyHASH_MODULUS
0026 #define _PyHASH_INF PyHASH_INF
0027 #define _PyHASH_IMAG PyHASH_IMAG
0028 
0029 /* Helpers for hash functions */
0030 PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double);
0031 
0032 // Kept for backward compatibility
0033 #define _Py_HashPointer Py_HashPointer
0034 
0035 
0036 /* hash function definition */
0037 typedef struct {
0038     Py_hash_t (*const hash)(const void *, Py_ssize_t);
0039     const char *name;
0040     const int hash_bits;
0041     const int seed_bits;
0042 } PyHash_FuncDef;
0043 
0044 PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
0045 
0046 PyAPI_FUNC(Py_hash_t) Py_HashPointer(const void *ptr);
0047 PyAPI_FUNC(Py_hash_t) PyObject_GenericHash(PyObject *);