mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
gh-122854: Add Py_HashBuffer() function (#122855)
This commit is contained in:
parent
3d60dfbe17
commit
d8e69b2c1b
17 changed files with 80 additions and 25 deletions
|
|
@ -89,6 +89,25 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
|
|||
|
||||
.. versionadded:: 3.13
|
||||
|
||||
|
||||
.. c:function:: 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
|
||||
:class:`bytes`, :class:`memoryview`, and other built-in objects
|
||||
that implement the :ref:`buffer protocol <bufferobjects>`.
|
||||
|
||||
Use this function to implement hashing for immutable objects whose
|
||||
:c:member:`~PyTypeObject.tp_richcompare` function compares to another
|
||||
object's buffer.
|
||||
|
||||
*len* must be greater than or equal to ``0``.
|
||||
|
||||
This function always succeeds.
|
||||
|
||||
.. versionadded:: 3.14
|
||||
|
||||
|
||||
.. c:function:: Py_hash_t PyObject_GenericHash(PyObject *obj)
|
||||
|
||||
Generic hashing function that is meant to be put into a type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue