[issue10356] decimal.py: hash of -1

Mark Dickinson report at bugs.python.org
Fri Nov 19 10:41:23 CET 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Ah, now I remember: making sNaNs hashable has the potential to introduce seemingly random exceptions with set and dict operations.  The logic went something like:

  (1) if sNaNs are hashable, you can put them in dicts,
  (2) operations on dicts make equality comparisons at (from the
      user's POV) unpredictable times (i.e., when hashes of two
      unequal objects happen to be equal), and
  (3) equality comparisons involving sNaNs raise an exception.

I'm wondering whether we should revisit the decision to have sNaN equalities raise an exception, and just have sNaN equality comparisons behave identically to those for (Decimal or float) NaNs in 3.2.

At any rate, if the code is left as is, the above logic should be added to the __hash__ function as a comment.

----------

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


More information about the Python-bugs-list mailing list