PyHash API
**********

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

type Py_hash_t

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

   在 3.2 版被加入.

type Py_uhash_t

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

   在 3.2 版被加入.

PyHASH_MODULUS

   用於數值雜湊方案的梅森質數 (Mersenne prime) "P = 2**n -1"。

   在 3.13 版被加入.

PyHASH_BITS

   "PyHASH_MODULUS" 中 "P" 的指數 "n"。

   在 3.13 版被加入.

PyHASH_MULTIPLIER

   用於字串和其他各種雜湊的質數乘數 (prime multiplier)。

   在 3.13 版被加入.

PyHASH_INF

   正無窮大回傳的雜湊值。

   在 3.13 版被加入.

PyHASH_IMAG

   用於複數虛數部分的乘數。

   在 3.13 版被加入.

type PyHash_FuncDef

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

   Py_hash_t (*const hash)(const void*, Py_ssize_t)

      雜湊函式。

   const char *name

      雜湊函式名稱（UTF-8 編碼字串）。

   const int hash_bits

      雜湊值的內部大小（以位元為單位）。

   const int seed_bits

      Seed 輸入的大小（以位元為單位）。

   在 3.4 版被加入.

PyHash_FuncDef *PyHash_GetFuncDef(void)

   取得雜湊函式定義。

   也參考:

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

   在 3.4 版被加入.

Py_hash_t Py_HashPointer(const void *ptr)

   雜湊指標值：將指標值作為整數處理（在內部轉型為 "uintptr_t"）。指標
   不會被取值 (dereference)。

   此函式不會失敗：它不會回傳 "-1"。

   在 3.13 版被加入.

Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len)

   Compute and return the hash value of a buffer of *len* bytes
   starting at address *ptr*. The hash is guaranteed to match that of
   "bytes", "memoryview", and other built-in objects that implement
   the buffer protocol.

   Use this function to implement hashing for immutable objects whose
   "tp_richcompare" function compares to another object's buffer.

   *len* 必須大於或等於 "0"。

   此函式總是會成功執行。

   在 3.14 版被加入.

Py_hash_t PyObject_GenericHash(PyObject *obj)

   泛用雜湊函式，旨在放入型別物件的 "tp_hash" 插槽中。其結果僅取決於物
   件的識別性。

   在 CPython 中，它等價於 "Py_HashPointer()"。

   在 3.13 版被加入.
