[issue36095] Better NaN sorting.

Brandt Bucher report at bugs.python.org
Sat Feb 23 18:45:28 EST 2019


Brandt Bucher <brandtbucher at gmail.com> added the comment:

Thanks for the feedback. I agree with you on the iffy delegation issue. However, this is problem that I feel deserves a fix... the behavior (silently producing garbage results) is just so un-pythonic. It’s been made clear in other issues that a warning isn’t right here, and sorting is guaranteed to use __lt__ (which NaN defines well for use in all other contexts). I honestly don’t see any other way. If that means fixing min, max, and friends too, I think it’s worth it.

Special cases justify special-casing, especially when doing so doesn’t break the rules. NaN isn’t like any other value of any other type; It’s practically defined by its ability to ruin valid comparison operations, even with fellow floats, for which ordering is otherwise well-defined.

For what it’s worth, I don’t know if anybody who’s tried to sort sets. Every Python programmer I know has blindly sorted floats at some point.

----------

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


More information about the Python-bugs-list mailing list