On Tue, Feb 4, 2020 at 10:12 AM Sebastian Berg
<sebast...@sipsolutions.net> 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?

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/6W2WWBXDD5H45DCGV4H2BRUSC3LI7JWD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to