Message28974
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? |
|
Date |
User |
Action |
Args |
2007-08-23 14:40:55 | admin | link | issue1514428 messages |
2007-08-23 14:40:55 | admin | create | |
|