Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
Currently the hash for integers and several other types uses 62 bits of 64 (on 64-bit platform). The domain of values is continuous: -sys.hash_info.modulus < h < sys.hash_info.modulus If interpret Py_hash_t as Py_uhash_t, it will no longer be continuous: 0 <= h < sys.hash_info.modulus or 2**sys.hash_info.width-sys.hash_info.modulus < h < 2**sys.hash_info.width The hash for tuples is written in term of signed hashes of elements. If write it in Python it will look more complicated for unsigned hashes. What are problems with using negative hash values? In hash tables you squeeze it to valid range by evaluating `h % size` of `h & mask`. Both expressions give non-negative result. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37807> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com