Well, *I* know the implementation. And I know about NaN being neither less
than or greater than anything else (even itself). And I know the basic
working of Timsort.

But a lot of other folks, especially beginners or casual users, don't know
all that.  The do know that fractional numbers are a thing one is likely to
want a median of (whether or not they know IEEE-754 intimately). And they
may or may not know that not-a-number is a float, but it's not that hard to
arrive at by a computation.

Even if documentation vaguely hints at the behavior, it's a source of
likely surprise. The fact that the median might be the very largest of a
bunch of numbers (with at least one NaN in the collection) is surely not
desired behavior, even if explainable.

Or e.g. two sets that compare as equal can have different medians according
to the statistics module. I can construct that example if needed.

On Thu, Dec 26, 2019, 12:27 PM Richard Damon

> Note that the statistics module documentation implies the issue, as median
> implies that it requires the sequence to be orderable, and nan isn't
> orderable. Since the statistics module seems to be designed to handle types
> other than floats, detecting nan values is extra expensive, so I think it
> can be excused for not checking.
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/PP27VNP23RNCA3MYSKRP7IXKVYLEXMZV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to