mirror of
https://github.com/python/cpython.git
synced 2026-01-05 06:52:26 +00:00
Restore removed private C API functions, macros and structures which have no simple replacement for now: * _PyDict_GetItem_KnownHash() * _PyDict_NewPresized() * _PyHASH_BITS * _PyHASH_IMAG * _PyHASH_INF * _PyHASH_MODULUS * _PyHASH_MULTIPLIER * _PyLong_Copy() * _PyLong_FromDigits() * _PyLong_New() * _PyLong_Sign() * _PyObject_CallMethodId() * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_EXTRA_INIT * _PyObject_FastCallDict() * _PyObject_GetAttrId() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyStack_AsDict() * _PyThread_CurrentFrames() * _PyUnicodeWriter structure * _PyUnicodeWriter_Dealloc() * _PyUnicodeWriter_Finish() * _PyUnicodeWriter_Init() * _PyUnicodeWriter_Prepare() * _PyUnicodeWriter_PrepareKind() * _PyUnicodeWriter_WriteASCIIString() * _PyUnicodeWriter_WriteChar() * _PyUnicodeWriter_WriteLatin1String() * _PyUnicodeWriter_WriteStr() * _PyUnicodeWriter_WriteSubstring() * _PyUnicode_AsString() * _PyUnicode_FromId() * _PyVectorcall_Function() * _Py_HashDouble() * _Py_HashPointer() * _Py_IDENTIFIER() * _Py_c_abs() * _Py_c_diff() * _Py_c_neg() * _Py_c_pow() * _Py_c_prod() * _Py_c_quot() * _Py_c_sum() * _Py_static_string() * _Py_static_string_init()
35 lines
1,009 B
C
35 lines
1,009 B
C
#ifndef Py_CPYTHON_HASH_H
|
|
# error "this header file must not be included directly"
|
|
#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_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
|
|
#define _PyHASH_INF 314159
|
|
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
|
|
|
|
/* Helpers for hash functions */
|
|
PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double);
|
|
PyAPI_FUNC(Py_hash_t) _Py_HashPointer(const void*);
|
|
|
|
|
|
/* hash function definition */
|
|
typedef struct {
|
|
Py_hash_t (*const hash)(const void *, Py_ssize_t);
|
|
const char *name;
|
|
const int hash_bits;
|
|
const int seed_bits;
|
|
} PyHash_FuncDef;
|
|
|
|
PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
|