Skip to content

Integer * int is slow #6199

@fredrik-johansson

Description

@fredrik-johansson
sage: a = 123
sage: b = 456
sage: c = 456r
sage: timeit("a*b")
625 loops, best of 3: 312 ns per loop
sage: timeit("a*c")
625 loops, best of 3: 2.99 µs per loop

Ditto for +, -. If I understand the code correctly, there always is a coercion to Integer, which could be avoided. I'm not sure how to best fix this since the ring operators are not implemented in the Integer class itself.

For division and shift, see #6083 and #6118.

CC: @robertwb

Component: basic arithmetic

Author: Robert Bradshaw

Reviewer: Fredrik Johansson, Mike Hansen, Craig Citro

Merged: sage-4.3.3.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/6199

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions