[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

Case Van Horsen report at bugs.python.org
Mon Oct 18 15:39:05 CEST 2010


Case Van Horsen <casevh at gmail.com> added the comment:

Some quick comments on the latest patch.

1) I don't think you can remove the type cast used when comparing the hash value against -1 and -2. IIRC, GCC considers that undefined behavior.

2) In sysmodule.c, we need to use PyLong_FromSsize_t when storing _PyHASH_MODULUS.

3) In pyport.h, we need a better way to define _PyHASH_MODULUS. The existing "((1UL << _PyHASH_BITS) - 1)" fails when unsigned long is smaller than Py_ssize_t. "((1ULL << _PyHASH_BITS) - 1)" works on 64-bit Windows but is not a good solution for systems that don't have an unsigned long long type. I haven't thought of a better solution for one.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9778>
_______________________________________


More information about the Python-bugs-list mailing list