Skip to content

Integer.__index__() currently goes via a python long #440

Closed
@sagetrac-dmharvey

Description

@sagetrac-dmharvey

Currently Integer.__index__() goes via a python long. In most cases the result should be just a python int, and it should be much faster to go directly there.

Probably the best way to implement this is to first call mpz_size(x.value) to check the size in words; if the size is one, then construct a python int directly; otherwise go to a long.

Even better might be to write another version of mpz_get_pylong which can produce a python int when that's feasible, or a long if it's not.

Component: basic arithmetic

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions