PyHash API

另請參閱PyTypeObject.tp_hash 成員和數值型別的雜湊

typePy_hash_t

雜湊值型別:有符號整數。

在 3.2 版被加入.

typePy_uhash_t

雜湊值型別:無符號整數。

在 3.2 版被加入.

PyHASH_MODULUS

TheMersenne primeP=2**n-1, used for numeric hash scheme.

在 3.13 版被加入.

PyHASH_BITS

The exponentn ofP inPyHASH_MODULUS.

在 3.13 版被加入.

PyHASH_MULTIPLIER

Prime multiplier used in string and various other hashes.

在 3.13 版被加入.

PyHASH_INF

The hash value returned for a positive infinity.

在 3.13 版被加入.

PyHASH_IMAG

The multiplier used for the imaginary part of a complex number.

在 3.13 版被加入.

typePyHash_FuncDef

PyHash_GetFuncDef() 所使用的雜湊函式定義。

constchar*name

雜湊函式名稱(UTF-8 編碼字串)。

constinthash_bits

雜湊值的內部大小(以位元為單位)。

constintseed_bits

Seed 輸入的大小(以位元為單位)。

在 3.4 版被加入.

PyHash_FuncDef*PyHash_GetFuncDef(void)

取得雜湊函式定義。

也參考

PEP 456「安全且可交替使用的雜湊演算法 (Secure and interchangeable hash algorithm)」。

在 3.4 版被加入.

Py_hash_tPy_HashPointer(constvoid*ptr)

Hash a pointer value: process the pointer value as an integer (cast it touintptr_t internally). The pointer is not dereferenced.

The function cannot fail: it cannot return-1.

在 3.13 版被加入.

Py_hash_tPyObject_GenericHash(PyObject*obj)

Generic hashing function that is meant to be put into a typeobject'stp_hash slot.Its result only depends on the object's identity.

CPython 實作細節: In CPython, it is equivalent toPy_HashPointer().

在 3.13 版被加入.