Skip to content

Provide Integer class with a __format__ method #12788

@nbruin

Description

@nbruin

It was observed in
this sage-support thread that Python new-style format specifiers for Sage Integers don't work. The solution is easy: Equip Integer with a __format__ method that simply converts the Sage Integer to a Python int and then calls the __format__ method on that. Given that converting a GMP int to a Python int should be much cheaper than converting either to a string, I don't expect much of a performance penalty, and implementing the whole Format mini-language again seems a waste of effort.

Component: basic arithmetic

Author: Nils Bruin

Reviewer: Mike Hansen

Merged: sage-5.0.beta12

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions