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 Dennis Sweeney
Recipients Dennis Sweeney, joel.larose
Date 2021-06-10.06:33:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623306804.08.0.775658430237.issue44370@roundup.psfhosted.org>
In-reply-to
Content
This is essentially the same issue, but with sorted(): https://bugs.python.org/issue36095

The trouble is that the implementation of min() is roughly equivalent to:

iterable = iter(iterable)
current_min = next(iterable)
for x in iterable:
    if x < current_min:
        current_min = x
return current_min

NaN < number and number < NaN both return false. Thus including NaNs make floats not totally ordered, so there's no perfect way to  sort them or take a max/min. This leads to some unexpected result, as you've identified. So you could say that the real "bug" is in floats more broadly.

This behavior was originally implemented to comply with IEEE 754. Even if that was a mistake, it would be very difficult to change this behavior in case someone's code relies on exactly using this implantation. I also don't like the idea of special-casing the behavior of min/max for floats, since right now the behavior is completely agnostic of the types of the items.
History
Date User Action Args
2021-06-10 06:33:24Dennis Sweeneysetrecipients: + Dennis Sweeney, joel.larose
2021-06-10 06:33:24Dennis Sweeneysetmessageid: <1623306804.08.0.775658430237.issue44370@roundup.psfhosted.org>
2021-06-10 06:33:24Dennis Sweeneylinkissue44370 messages
2021-06-10 06:33:23Dennis Sweeneycreate