gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)

This commit is contained in:
Serhiy Storchaka 2024-03-22 20:19:10 +02:00 committed by GitHub
parent 567ab3bd15
commit e2e0b4b4b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 51 additions and 13 deletions

View file

@ -82,3 +82,14 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
The function cannot fail: it cannot return ``-1``.
.. versionadded:: 3.13
.. c:function:: 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.
.. impl-detail::
In CPython, it is equivalent to :c:func:`Py_HashPointer`.
.. versionadded:: 3.13

View file

@ -883,6 +883,10 @@ and :c:data:`PyType_Type` effectively act as defaults.)
:c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash`, when the subtype's
:c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``.
**Default:**
:c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`.
.. c:member:: ternaryfunc PyTypeObject.tp_call