[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)
report at bugs.python.org
Tue Oct 19 09:15:07 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
> The calculation of long_hash assumes an unsigned temporary type to get
> correct results for the bit shifting and masking.
> The calculation is
> done on the absolute value of the long and then the sign is applied. We
> either needed to (1) add an unsigned Py_hash_t type or (2) just use
> size_t and Py_ssize_t.
I like (2); the use of Py_hash_t suggests to me that the type used for the hash is configurable independently of Py_ssize_t, which isn't true.
Also, with Py_hash_t it's no longer clear that printing a hash value (e.g., using PyErr_Format and friends) should use the '%zd' modifier.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list