Tim Peters <t...@python.org> added the comment:

If we could roll back the clock, I'd impose a total ordering on floats in 
Python and supply some other way to spell 754's comparison operators (which 
users would have to ask for explicitly if they wanted to hassle with the 
near-useless and too-often-surprising "unordered" outcome).

But, too late.  As is, I don't want to mess up every context that _uses_ 
comparisons under the covers to make a special case out of NaNs.  Floats are a 
partially ordered type, and live with the consequences.

Which are approximately none for me ;-)  I rarely have a use for a NaN to begin 
with, and never in a list I intend to sort.

That said, the one thing that gives me pause is this line from numpy's docs:

   https://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html
    "In numpy versions >= 1.4.0 nan values are sorted to the end."

But that's not the end of it:

    
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html
    ...
    na_position : {‘first’, ‘last’}, default ‘last’
    first puts NaNs at the beginning, last puts NaNs at the end

So people who go down this path can't get two steps before making a fork in the 
road ;-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36095>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to