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
Date 2007-01-06.02:05:55
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The Decimal Arithmetic Specification says that NaN comparisons should return NaN.  The decimal module correctly implements this through the compare() method:

    >>> nan.compare(nan)
    Decimal('NaN')

Since python's < and > operators return a boolean result, the standard is silent on what should be done.  The current implementation uses the __cmp__ method which can only return -1, 0, or 1, so there is not a direct way to make both < and > both return False.

If you want to go beyond the standard and have both < and > return False for all NaN comparisons, then the __cmp__ implementation would need to be replaced with rich comparisons.  I'm not sure that this is desirable.  IMO, that would be no better than the current arbitrary choice where all comparisons involving NaN report self > other.  If someone has an application that would be harmed by the current implementation, then it should almost certainly be use the standard compliant compare() method instead of the boolean < and > operators.

Tim, what say you?
History
Date User Action Args
2007-08-23 14:40:55adminlinkissue1514428 messages
2007-08-23 14:40:55admincreate