-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make _Py_HashDouble
public again as "unstable" API
#111545
Comments
cc @vstinner, per the What's New |
I would prefer a public API rather than a private API. I don't expect Py_HashDouble() API to be unstable. See also issue #111389.
Thanks. I'm trying to keep track of these issues under #111481 meta issue. |
Move non-limited C API to a new Include/cpython/pyhash.h header file.
Move non-limited C API to a new Include/cpython/pyhash.h header file.
Move non-limited C API to a new Include/cpython/pyhash.h header file.
* Cleanup _Py_HashDouble() implementation. * Add Lib/test/test_capi/test_hash.py. * Add Modules/_testcapi/hash.c.
* Cleanup _Py_HashDouble() implementation. * Add Lib/test/test_capi/test_hash.py. * Add Modules/_testcapi/hash.c.
* Cleanup _Py_HashDouble() implementation. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Cleanup PyHash_Double() implementation based _Py_HashDouble(): * Move variable declaration to their first assignment. * Add braces (PEP 7). * Cast result to signed Py_hash_t before the final "== -1" test, to reduce the number of casts. * Add an assertion on Py_IS_NAN(v) in the only code path which can return -1. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add _Py_rotateright_uintptr() function with tests. * Add tests on PyHash_Pointer() to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add _Py_rotateright_uintptr() function with tests. * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Cleanup PyHash_Double() implementation based _Py_HashDouble(): * Move variable declaration to their first assignment. * Add braces (PEP 7). * Cast result to signed Py_hash_t before the final "== -1" test, to reduce the number of casts. * Add an assertion on Py_IS_NAN(v) in the only code path which can return -1. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add _Py_rotateright_uintptr() function with tests. * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add _Py_rotateright_uintptr() function with tests. * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Keep _Py_HashPointer() function as an alias to PyHash_Pointer(). * Add PyHash_Pointer() tests to test_capi.test_hash. * Remove _Py_HashPointerRaw() function: inline code in _Py_hashtable_hash_ptr().
* Add again _PyHASH_NAN constant. * _Py_HashDouble(NULL, value) now returns _PyHASH_NAN. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Add again _PyHASH_NAN constant. * _Py_HashDouble(NULL, value) now returns _PyHASH_NAN. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Add again the private _PyHASH_NAN constant. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* 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().
* 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().
* 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().
* 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().
I wonder whether it is worth to add the |
* Add again the private _PyHASH_NAN constant. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Add again the private _PyHASH_NAN constant. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* 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().
* 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().
* Add again the private _PyHASH_NAN constant. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* Add again the private _PyHASH_NAN constant. * Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
Add tests: Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* 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().
It was decided to not add a public API for now: capi-workgroup/decisions#2 (comment) |
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* 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().
In NumPy we use
_Py_HashDouble
for our floating point hashing needs and that seems like a pretty good candiate for the unstable API to me: #91744 (comment) and #101101 (comment).However, the function is currently removed rather than made unstable (to my understanding). While it should probably be easy enough to vendor what we needed, I would prefer the unstable API tier, it gives a better sense of having the required identical hashing.
NumPy issue: numpy/numpy#25035
Originally reported by @ngoldbaum in #111418 (comment)
Linked PRs
The text was updated successfully, but these errors were encountered: