On Tue, Feb 4, 2020 at 10:12 AM Sebastian Berg email@example.com wrote:
Now, probably this has been rejected a hundred times before, and there are some very good reason why it is a horrible thought...
But if `PyObject_RichCompareBool(..., Py_EQ)` is such a fundamental operation (and in a sense it seems to me that it is), is there a point in explicitly defining it?
That would mean adding `operator.equivalent(a, b) -> bool` which would allow float to override the result and let `operator.equivalent_value(float("NaN"), float("NaN))` return True; luckily very few types would actually override the operation.
That operator would obviously be allowed to use the shortcut.
At that point container `==` and `in` (and equivalence) is defined based on element equivalence. NAs (missing value handling) may be an actual use-case where it is more than a theoretical thought. However, I do not seriously work with NAs myself.
The implication here is that there would be a corresponding dunder method, yes? If it's possible for a type to override it, that would need a dunder. I think that's not necessary; but if there were some useful name that could be given to this "identical or equal" comparison, then I think it'd be useful to (a) put that function into the operator table, and (b) use that name in the description of container operations.
Can the word "equivalent" be used for this, perhaps?