#6199: Integer * int is slow
-------------------------------+--------------------------------------------
Reporter: fredrik.johansson | Owner: somebody
Type: defect | Status: closed
Priority: major | Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic | Resolution: wontfix
Keywords: | Author:
Upstream: N/A | Reviewer:
Merged: | Work_issues:
-------------------------------+--------------------------------------------
Comment(by fredrik.johansson):
Craig, thanks for investigating. This is, unfortunately, quite critical
for improving mpmath's performance, and the only other solution is not to
use sage.Integer.
I haven't touched Cython in a while now, but... I'm still not clear about
why Integer multiplication has to go through the generic ring
multiplication code. Wouldn't it be possible to extend the
coercion/operator code so that any subclass can overload it? Something
like (in regular Python, made-up method names):
{{{
class RingElement:
def __mul__(self, other):
self, other = self.coerce(other)
return self._mul_coerced(self, other)
class Integer(RingElement):
def __mul__(self, other):
if type(other) is int:
return self._mul_int(other)
return RingElement.__mul__(self, other)
def _mul_coerced(self, other):
# multiply two Integers
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6199#comment:4>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.