Adding Py_HashBuffer to the Stable ABI #148233
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
The function Py_HashBuffer was added in PR: #122854
This was included in Python 3.14
Would like to propose adding this to the Stable ABI
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
This came up in discussion in the PR, but hadn't been done there as it wasn't determined previously. So would like to open this discussion
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Activity
picnixz commentedon Apr 8, 2026
cc @vstinner
vstinner commentedon Apr 9, 2026
The function is properly documented and tested (by
test_capi.test_hash). It has a well defined API. It's a good candidate for the stable ABI.vstinner commentedon Apr 9, 2026
I went ahead and created github.com/capi-workgroup/decisions/issues/102 in the C API Working Group.
vstinner commentedon Sep 22, 2026
The C API Working Group voted in favor of adding Py_HashBuffer() to the stable ABI. I created #157966 to move Py_HashBuffer() to the limited C API.
gh-148233: Add Py_HashBuffer() to the limited C API (#157966)
vstinner commentedon Sep 23, 2026
I merged my PR. Py_HashBuffer() is now available on Python 3.16 limited C API. Thanks for your suggestion @jakirkham.
On older versions, I suppose that you should create a bytes string and call PyObject_Hash().
pythongh-148233: Group stable_abi.toml entries per Python version
gh-148233: Group stable_abi.toml entries per Python version (GH-157990)
[3.15] gh-158886: Add INCREF/DECREF macros to stable_abi.toml (GH-158941
[3.14] gh-158886: Add INCREF/DECREF macros to stable_abi.toml (GH-158941
jakirkham commentedon Oct 13, 2026
Thank you Victor! Appreciate your help navigating this process 🙏
vstinner commentedon Oct 13, 2026
FYI I added the function to pythoncapi-compat with this implementation for older Python versions: