#20731: shortcut coercion for Integer-Rational operations
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-7.3
Component: coercion | Resolution:
Keywords: days74 | Merged in:
Authors: Vincent Delecroix | Reviewers: Jeroen Demeyer,
| Travis Scrimshaw
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/20731 | 1a93a12c39522dbe60b958757e2e3922aa9c23ed
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by tscrim):
* reviewer: => Jeroen Demeyer, Travis Scrimshaw
Comment:
Ah, I see it now. I guess the only difference is checking `isinstance` for
`Integer` is longer than that of `Rational` because of a shorter MRO:
{{{
sage: p = 2
sage: p.__class__.__mro__
(<type 'sage.rings.integer.Integer'>,
<type 'sage.structure.element.EuclideanDomainElement'>,
<type 'sage.structure.element.PrincipalIdealDomainElement'>,
<type 'sage.structure.element.DedekindDomainElement'>,
<type 'sage.structure.element.IntegralDomainElement'>,
<type 'sage.structure.element.CommutativeRingElement'>,
<type 'sage.structure.element.RingElement'>,
<type 'sage.structure.element.ModuleElement'>,
<type 'sage.structure.element.Element'>,
<type 'sage.structure.sage_object.SageObject'>,
<type 'object'>)
sage: q = 2/3
sage: q.__class__.__mro__
(<type 'sage.rings.rational.Rational'>,
<type 'sage.structure.element.FieldElement'>,
<type 'sage.structure.element.CommutativeRingElement'>,
<type 'sage.structure.element.RingElement'>,
<type 'sage.structure.element.ModuleElement'>,
<type 'sage.structure.element.Element'>,
<type 'sage.structure.sage_object.SageObject'>,
<type 'object'>)
}}}
I'm happy with this ticket as-is. Jeroen, any more comments?
--
Ticket URL: <https://trac.sagemath.org/ticket/20731#comment:37>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.