[Python-ideas] Make max() stable

random832 at fastmail.us random832 at fastmail.us
Tue Jan 21 21:31:02 CET 2014


On Sat, Jan 18, 2014, at 5:40, Devin Jeanpierre wrote:
> On Sat, Jan 18, 2014 at 12:12 AM, Steven D'Aprano <steve at pearwood.info>
> wrote:
> > These variations only are meaningful if a and b are different types
> > with the same value, or the same type but different identities. Even if
> > these variations are important, I don't think there is any inherent
> > benefit to one over the other.
> 
> These variations are also important if a and b are just plain
> different values, same type or no. This can happen if max/min are
> passed a key function -- equality of a sort key doesn't mean the
> values are interchangeable for all purposes

I suspect you're getting hung up on two definitions of "value" - or
maybe two definitions of "identity".

Apropos of nothing, both functions will return NaN if it is the first
element of the list, but not if it is in any other position. Of course,
the behavior of sorting is also unreliable when faced with lists
containing NaN.


More information about the Python-ideas mailing list