Some operations are not basic operations. Take max
as an example, it is actually an operation based on comparison. In other words, when you get a max value, you are actually getting a biggest value.
So in this case, why should we implement a specified max
function but not override the behave of comparison?
Think in another direction, what does max
really mean? For example, when we execute max(list)
, what are we doing?
I think we are actually checking list
's elements, and the max
operation is not related to list
itself at all.
list
is just a container which is unnecessary in max
operation. It is list
or set
or something else, it doesn't matter. What really useful is the elements inside this container.
So if we define a __max__
action for list
, we are actually doing another totally different operation. We are asking a container to give us advice about max value.
I think in this case, as it is a totally different operation, it should be a method of container instead of overriding built-in function's behave.