Message274573
As a convenience for whom? Certainly not the poor user, who thinks that
math.isnan(x) should return False if the number x is not a NAN. Since
neither 10**1 nor 10**100000 are NANs, why should one return correctly
and the other raise a completely spurious OverflowError?
I cannot speak for the implementation, except as a wild guess. It
shouldn't be hard to do the equivalent of:
if type(x) == int: return False # Intentionally excluding subclasses.
try:
y = float(x)
except OverflowError:
return False
else:
... # existing implementation
but since I know nothing about the C implementation maybe I'm completely
wrong. But as far as the user's cognitive load, I don't think that:
"math.isnan(x) might return the expected result, or it might raise
OverflowError"
is *simpler* for the user than:
"math.isnan(x) will return the expected result". |
|
Date |
User |
Action |
Args |
2016-09-06 17:47:18 | steven.daprano | set | recipients:
+ steven.daprano, mark.dickinson |
2016-09-06 17:47:18 | steven.daprano | link | issue27975 messages |
2016-09-06 17:47:18 | steven.daprano | create | |
|