Marco Sulla <launchpad....@marco.sulla.e4ward.com> added the comment:

I'm in favor of a `math.total_ordering` function, but IMHO sorting functions 
should emit a warning if they contains an unorderable objects.

This can be done easily: I suppose the sorting function checks if the objects 
of the iterable are minor that another object. And soon or later, this check 
will be done for all objects in the iterable.

What I propose is simply to add a flag `all_orderables`, true by default.

After the current object a is checked against the object b, if `all_orderables` 
is true, another check will be performed: `a >= b`?

If this return false, `all_orderables` will be set to false.

At the end of sorting, if `all_orderables` is false, a warning will be emitted.

This way, no old code will break, but developers will be informed of the 
problem. Because "Errors should never pass silently" :)

----------
nosy: +Marco Sulla

_______________________________________
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