[docs] [issue9802] Document 'stability' of builtin min() and max()

Antoine Pitrou report at bugs.python.org
Sun Sep 12 14:52:39 CEST 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

> As an aside, I still like Jeffrey Yasskin's suggestion on the
> python-dev mailing list that the sensible definition for max would
> maintain the invariant that max(iterable) be equivalent to
> sorted(iterable)[-1]

What's interesting is the practical consequence that:

x, y = min(x, y), max(x, y)

cannot give you twice the same object.

Of course, there are subtle implications of how it will be implemented (especially with objects which have a partial order relationship to each other). Since max() is supposed to work on any iterator, we probably don't want to build an intermediate sequence and fetch elements in reverse order; instead perhaps use (not Py_LT) instead of Py_GT.

----------
nosy: +pitrou
versions: +Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9802>
_______________________________________


More information about the docs mailing list