This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients mark.dickinson, njs, rhettinger, serhiy.storchaka, tim.peters
Date 2019-08-11.23:57:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> What killer use case am I missing?

There's no killer use case. I just thought it weird that hte builtin hash() function ever returned a negative number.

> This is a change of documented behaviour that will affect 
> 3rd party libraries that provide numeric types, like NumPy
> and gmpy; it should not be done lightly.

Okay, I'm happy to drop this.  It was only a minor nuisance.

Am not sure at what point we ever guaranteed that hash() would return negative numbers, or any particular number.  That was probably a mistake.  I thought the guarantees were all higher level metamorphic invariants such as hash(x) == hash(y) when x == y and {type(x), type(y)} ⊂ {bool, int, float, Decimal, Fraction, complex}.

BTW, I'm not sure why the numeric hashes are not getting all 64 bits in to play:

    from random import randrange, expovariate
    from secrets import token_hex, token_bytes

    for random_hash in [
        lambda : hash(randrange(2**100)) % 2**64,
        lambda : abs(hash(expovariate(1.0))) % 2**64,
        lambda : hash(token_hex()) % 2**64,
        lambda : hash(token_bytes()) % 2**64,
        print(max(random_hash().bit_length() for i in range(10_000)))


Date User Action Args
2019-08-11 23:57:49rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, njs, serhiy.storchaka
2019-08-11 23:57:49rhettingersetmessageid: <>
2019-08-11 23:57:49rhettingerlinkissue37807 messages
2019-08-11 23:57:49rhettingercreate