Steven D'Aprano added the comment:
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".
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27975>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com