Message415934
> We cannot guarantee that NAN never equal to anything, because we can
> create an object equal to it. For example mock.ANY
Sure. I don't expect that mock.ANY or other weird objects should obey
the IEEE-754 rules. But we're talking numeric comparisons here, not
arbitrary objects which may do arbitrary things in their `__eq__`
method.
The documentation for the math module assumes we're talking about
sensible, standard numeric values that don't play strange tricks on the
caller. Look at the first function documented:
math.ceil(x)
Return the ceiling of x, the smallest integer greater than or equal to
x. If x is not a float, delegates to x.__ceil__(), which should return
an Integral value.
class MyWeirdFloat(float):
def __ceil__(self):
return -1
math.ceil(MyWeirdFloat(25.9)) # Returns -1 instead of the ceiling.
Does the documentation really need to cover every imaginable weird
class? I don't think so. Let's keep it simple. NANs compared unequal
with all numeric values which directly or indirectly obey IEEE-754,
which includes floats. |
|
Date |
User |
Action |
Args |
2022-03-24 10:42:44 | steven.daprano | set | recipients:
+ steven.daprano, docs@python, serhiy.storchaka, veky, slateny, CharlieZhao |
2022-03-24 10:42:44 | steven.daprano | link | issue47031 messages |
2022-03-24 10:42:44 | steven.daprano | create | |
|