PyHash API¶
See also the PyTypeObject.tp_hash
member and 数字类型的哈希运算.
-
type Py_hash_t¶
哈希值类型:有符号整数。
Added in version 3.2.
-
type Py_uhash_t¶
哈希值类型:无符号整数。
Added in version 3.2.
-
PyHASH_MODULUS¶
The Mersenne prime
P = 2**n -1
, used for numeric hash scheme.Added in version 3.13.
-
PyHASH_BITS¶
The exponent
n
ofP
inPyHASH_MODULUS
.Added in version 3.13.
-
PyHASH_INF¶
The hash value returned for a positive infinity.
Added in version 3.13.
-
PyHASH_IMAG¶
The multiplier used for the imaginary part of a complex number.
Added in version 3.13.
-
type PyHash_FuncDef¶
PyHash_GetFuncDef()
使用的哈希函数定义。-
const char *name¶
哈希函数名称(UTF-8 编码的字符串)。
-
const int hash_bits¶
以比特位表示的哈希值内部大小。
-
const int seed_bits¶
以比特位表示的输入种子值大小。
Added in version 3.4.
-
const char *name¶
-
PyHash_FuncDef *PyHash_GetFuncDef(void)¶
获取哈希函数定义。
参见
PEP 456 "安全且可互换的哈希算法"。
Added in version 3.4.
-
Py_hash_t Py_HashPointer(const void *ptr)¶
Hash a pointer value: process the pointer value as an integer (cast it to
uintptr_t
internally). The pointer is not dereferenced.The function cannot fail: it cannot return
-1
.Added in version 3.13.
-
Py_hash_t PyObject_GenericHash(PyObject *obj)¶
Generic hashing function that is meant to be put into a type object's
tp_hash
slot. Its result only depends on the object's identity.CPython 实现细节: In CPython, it is equivalent to
Py_HashPointer()
.Added in version 3.13.