gh-134891: Add PyUnstable_Unicode_GET_CACHED_HASH (GH-134892)

This commit is contained in:
Petr Viktorin 2025-06-06 15:51:00 +02:00 committed by GitHub
parent 343182853f
commit e413e26719
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 55 additions and 5 deletions

View file

@ -191,6 +191,22 @@ access to internal read-only data of Unicode objects:
.. versionadded:: 3.2
.. c:function:: Py_hash_t PyUnstable_Unicode_GET_CACHED_HASH(PyObject *str)
If the hash of *str*, as returned by :c:func:`PyObject_Hash`, has been
cached and is immediately available, return it.
Otherwise, return ``-1`` *without* setting an exception.
If *str* is not a string (that is, if ``PyUnicode_Check(obj)``
is false), the behavior is undefined.
This function never fails with an exception.
Note that there are no guarantees on when an object's hash is cached,
and the (non-)existence of a cached hash does not imply that the string has
any other properties.
Unicode Character Properties
""""""""""""""""""""""""""""