[issue9802] Document 'stability' of builtin min() and max()
Mark Dickinson
report at bugs.python.org
Mon Sep 13 21:38:00 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
> Of course, there are subtle implications of how it will be implemented
Indeed. Ideally, as you mention, the implementation would only use __lt__ (as with sort and bisect). I think that constraint only leaves one reasonable choice: namely, max and min for multiple args would be functionally equivalent to max_list and min_list below:
def min2(x, y):
return y if y < x else x
def max2(x, y):
return x if y < x else y
def min_list(xs):
return reduce(min2, xs)
def max_list(xs):
return reduce(max2, xs)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9802>
_______________________________________
More information about the Python-bugs-list
mailing list