[issue7279] decimal.py: == and != comparisons involving NaNs

Mark Dickinson report at bugs.python.org
Tue Mar 23 15:57:47 CET 2010


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

Re-opening to address a couple of points that came out of the python-dev discussion:

(1) As Stefan pointed out on python-dev, equality and inequality comparisons involving signaling nans should signal (order comparisons already do).  IEEE 754 is fairly clear on this.  From section 6.2:

"""Signaling NaNs shall be reserved operands that, under default exception handling, signal the invalid operation exception (see 7.2) for every general-computational and signaling-computational operation except for the conversions described in 5.12."""

(Comparisons fall under 'signaling-computational operations, in section 5.6 of the standard.)

I propose to fix this for 2.7 and 3.2.

(2) Currently hash(Decimal("nan")) raises a TypeError.  I can see no good reason for this at all;  it's possible to hash float nans and to put them in sets and dictionaries.  I propose to remove this restriction for 2.7 and 3.2.  I think hash(Decimal("snan")) should also succeed:  *computational* operations on signaling nans should signal, but I don't think that putting a signaling nan into a dict, or checking for its presence in a list, counts as a computational operation for this purpose.

----------
assignee:  -> mark.dickinson
priority:  -> high
status: closed -> open

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


More information about the Python-bugs-list mailing list