summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-12-06 14:09:22 (GMT)
committerGitHub <noreply@github.com>2023-12-06 14:09:22 (GMT)
commit828451dfde324f9499ffebc023a22b84dc5a125b (patch)
treeceee17c26f9c9238b602ef9156e6eb8530d032f1 /Doc
parentf8852634edf1232ac1aa4561e34796b52f9f7aa2 (diff)
downloadcpython-828451dfde324f9499ffebc023a22b84dc5a125b.zip
cpython-828451dfde324f9499ffebc023a22b84dc5a125b.tar.gz
cpython-828451dfde324f9499ffebc023a22b84dc5a125b.tar.bz2
gh-111545: Add Py_HashPointer() function (#112096)
* Implement _Py_HashPointerRaw() as a static inline function. * Add Py_HashPointer() tests to test_capi.test_hash. * Keep _Py_HashPointer() function as an alias to Py_HashPointer().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/hash.rst10
-rw-r--r--Doc/whatsnew/3.13.rst3
2 files changed, 13 insertions, 0 deletions
diff --git a/Doc/c-api/hash.rst b/Doc/c-api/hash.rst
index 3bfaf8b..91d88ae 100644
--- a/Doc/c-api/hash.rst
+++ b/Doc/c-api/hash.rst
@@ -49,3 +49,13 @@ See also the :c:member:`PyTypeObject.tp_hash` member.
:pep:`456` "Secure and interchangeable hash algorithm".
.. versionadded:: 3.4
+
+
+.. c:function:: Py_hash_t Py_HashPointer(const void *ptr)
+
+ Hash a pointer value: process the pointer value as an integer (cast it to
+ ``uintptr_t`` internally). The pointer is not dereferenced.
+
+ The function cannot fail: it cannot return ``-1``.
+
+ .. versionadded:: 3.13
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 534813f..c9facad 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -1249,6 +1249,9 @@ New Features
:exc:`KeyError` if the key missing.
(Contributed by Stefan Behnel and Victor Stinner in :gh:`111262`.)
+* Add :c:func:`Py_HashPointer` function to hash a pointer.
+ (Contributed by Victor Stinner in :gh:`111545`.)
+
Porting to Python 3.13
----------------------