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 steven.daprano
Recipients CharlieZhao, docs@python, serhiy.storchaka, slateny, steven.daprano, veky
Date 2022-03-24.10:42:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20220324104109.GN8276@ando.pearwood.info>
In-reply-to <1647681720.77.0.488206313713.issue47031@roundup.psfhosted.org>
Content
> 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.
History
Date User Action Args
2022-03-24 10:42:44steven.dapranosetrecipients: + steven.daprano, docs@python, serhiy.storchaka, veky, slateny, CharlieZhao
2022-03-24 10:42:44steven.dapranolinkissue47031 messages
2022-03-24 10:42:44steven.dapranocreate