[issue32118] Docs: add note about sequence comparisons containing non-orderable elements

R. David Murray report at bugs.python.org
Thu Nov 23 11:12:57 EST 2017


R. David Murray <rdmurray at bitdance.com> added the comment:

The surprising thing is the behavior of NaN, which is *not equal* to itself.

The statement about orderability says "...are ordered the same as their first unequal elements".  This is explicit and unambiguous, there is no difference in this context between the number 1 and the singleton None, or the reflexivity enforced on NaN: all are equal to the corresponding element from the other sequence.  The whole point of the paragraph is that *no order test is done until the first unequal element is encountered*.

If we want to make this *more* explicit, I would suggest simply adding the following sentence after the first example in the original paragraph: "This means that reflexive elements that are otherwise unorderable (such as None and NaN) do not trigger a TypeError during a comparison."

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32118>
_______________________________________


More information about the Python-bugs-list mailing list