Python's Max() Is Broken(mathspp.com)
mathspp.com
Python's Max() Is Broken
https://mathspp.com/blog/max-is-broken
3 comments
Imho this is a non-issue. Python's max-function isn't limited to numerical values, but can consume iterables of anything with a defined order, i.e., things that implement the appropriate hooks in the Python data model. For such inputs, returning anything but an error (or the optionally provided default value) doesn't make much sense.
I wonder what would happen if you modified the interpreter to do this by default, and then ran a comprehensive test suite across a wide range of commonly used packages.
At the very least it would be intersting to find code that calls max([]).
At the very least it would be intersting to find code that calls max([]).
I think one potential downside of this is you no longer have `max(l) in l` for all lists.