Fix misinformation about NaN != NaN comparison (GH-19357)

This commit is contained in:
Mark Dickinson 2020-04-05 10:25:24 +01:00 committed by GitHub
parent 909f4a3009
commit 810f68f128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1422,8 +1422,9 @@ built-in types.
The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are
special. Any ordered comparison of a number to a not-a-number value is false. special. Any ordered comparison of a number to a not-a-number value is false.
A counter-intuitive implication is that not-a-number values are not equal to A counter-intuitive implication is that not-a-number values are not equal to
themselves. For example, if ``x = float('NaN')``, ``3 < x``, ``x < 3``, ``x themselves. For example, if ``x = float('NaN')``, ``3 < x``, ``x < 3`` and
== x``, ``x != x`` are all false. This behavior is compliant with IEEE 754. ``x == x`` are all false, while ``x != x`` is true. This behavior is
compliant with IEEE 754.
* ``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that * ``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that
comparisons for singletons should always be done with ``is`` or ``is not``, comparisons for singletons should always be done with ``is`` or ``is not``,