-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add PyObject_GenericHash() function #5
Comments
+1 on the idea. I agree with the direction this is taking us, but I feel that this direction should be noted explicitly: For this function specifically, I'd prefer calling it |
+1 to add the function. Using |
+1 on the function too. It looks like a great idea. Regarding the name, why not just |
👍 |
That's a different function -- the equivalent of |
Doh! Thanks for explaining. Now that I understand a bit better, having a function that returns a |
On other hand, this API itself is not very useful without adding a corresponding API for As for a name, we have |
I added Py_Is(x, y) function. Are you referring to that? |
Ping @iritkatriel and @gvanrossum: what's your opinion on this API? |
Looks like we're all in favor now. |
@serhiy-storchaka: Congrats, your API is approved, you can go ahead ;-) |
Issue: python/cpython#113024
PR: python/cpython#113025
Py_hash_t PyObject_GenericHash(PyObject *obj)
It is the implementation of the default Python object hashing function
object.__hash__()
. In CPython it is identical toPy_HashPointer()
, but has the signature compatible withtp_hash
. It can only be used for Python objects, not arbitrary pointers, and it is more portable. It can be used in implementations that have no equivalence between object identity and object address.PyObject_GenericHash()
should be used for calculating the hash of Python object.Py_HashPointer()
should be used for pointers not managed by Python object manger (i.e. static data, malloced data or pointers to C functions likewrapperobject.descr
).The text was updated successfully, but these errors were encountered: