-
-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In richcmp, fall back to reversed operation if coercion fails #21163
Milestone
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Commit: |
New commits:
|
comment:8
ok, looks good to me. Nice formula for the revop involution. |
Reviewer: Frédéric Chapoton |
comment:9
Replying to @fchapoton:
Thanks. That was a nice exercise :-) |
Changed branch from u/jdemeyer/in_richcmp__fall_back_to_reversed_operation_if_coercion_fails to |
This was referenced Apr 29, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change the implementation of
x.__richcmp__(y, op)
to tryy.__richcmp__(x, revop)
ify
not a SageElement
and coercion fails. In Python terms: ifx.__ge__(y)
fails, tryy.__le__(x)
. This is precisely what Python does when a comparison returnsNotImplemented
.If this reversed operation is not implemented (either the type does not define comparisons or the comparison returns
NotImplemented
), go on as usual. Because of this, we cannot just returnNotImplemented
in the coercion model, we need to implement the reversing ourselves.In #20767, the analogous thing was done for arithmetic.
Component: coercion
Author: Jeroen Demeyer
Branch/Commit:
b3ea04f
Reviewer: Frédéric Chapoton
Issue created by migration from https://trac.sagemath.org/ticket/21163
The text was updated successfully, but these errors were encountered: