Skip to content

Simplify mpz.__format__(), part 3 - #373

Merged
skirpichev merged 11 commits into
diofant:masterfrom
skirpichev:simplify-format/358
Oct 11, 2026
Merged

skirpichev merged 11 commits into
diofant:masterfrom
skirpichev:simplify-format/358

Conversation

@skirpichev

@skirpichev skirpichev commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Closes #358

@skirpichev skirpichev added this to the 0.6 milestone Oct 7, 2026
@skirpichev
skirpichev force-pushed the simplify-format/358 branch 3 times, most recently from 5d23a4f to acd235a Compare October 10, 2026 10:39
@skirpichev
skirpichev marked this pull request as ready for review October 10, 2026 10:40
@skirpichev

skirpichev commented Oct 11, 2026 •

Copy link
Copy Markdown
Member Author

from #188 (comment)

Benchmark gmpy2 ref-v0.5.4 patch int
format(123, '20d') 4.33 us 2.69 us: 1.61x faster 1.03 us: 4.20x faster 922 ns: 4.70x faster
format(-1234, '030x') 3.24 us 2.01 us: 1.61x faster 1.08 us: 3.00x faster 840 ns: 3.86x faster
Geometric mean (ref) 1.61x faster 3.55x faster 4.26x faster
Details
# bench.py
import pyperf
from gmp import mpz
from gmpy2 import mpz as mpz2
#mpz = int
#mpz = mpz2

runner = pyperf.Runner()
for v, f in [("123", "20d"), ("-1234", "030x")]:
    n = mpz(eval(v))
    v = "format(" + v + ", " + repr(f) + ")"
    runner.bench_func(v, format, n, f)

@skirpichev
skirpichev merged commit 3e301ab into diofant:master Oct 11, 2026
24 of 25 checks passed
@skirpichev
skirpichev deleted the simplify-format/358 branch October 11, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assume ASCII in format strings

1 participant