[issue43475] Worst-case behaviour of hash collision with float NaN

Raymond Hettinger report at bugs.python.org
Sat Apr 10 03:14:42 EDT 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Mark, is there any reason hash(float('NaN')) and hash(Decimal('NaN')) have to be a constant?  Since NaNs don't compare equal, the hash homomorphism has no restrictions.  Why not have hash() return the id() like we do for instances of object?

I understand that sys.hash_info.nan would be invalidated, but that was likely useless anyway.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43475>
_______________________________________


More information about the Python-bugs-list mailing list