Skip to content

Support integer formatting types for mpz#188

Merged
skirpichev merged 1 commit intodiofant:masterfrom
skirpichev:format/7
Jul 8, 2025
Merged

Support integer formatting types for mpz#188
skirpichev merged 1 commit intodiofant:masterfrom
skirpichev:format/7

Conversation

@skirpichev
Copy link
Copy Markdown
Member

@skirpichev skirpichev commented Jul 7, 2025

  • port CPython helpers
  • use only public api in fill_number(), etc
  • cleanup drop toupper/forward options

Closes #7

@skirpichev skirpichev force-pushed the format/7 branch 2 times, most recently from 693adba to ab9dc29 Compare July 7, 2025 18:04
* port CPython helpers
* use only public api in fill_number(), etc
* cleanup drop toupper/forward options

Closes diofant#7
@skirpichev skirpichev marked this pull request as ready for review July 8, 2025 06:15
@skirpichev
Copy link
Copy Markdown
Member Author

Benchmark ref patch
format(123, '20d') 2.15 us 2.03 us: 1.06x faster
format(-1234, '030x') 2.03 us 1.91 us: 1.06x faster
Geometric mean (ref) 1.06x faster
Details
# bench.py
import pyperf
from gmp import mpz

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 ce09c9c into diofant:master Jul 8, 2025
18 checks passed
@skirpichev skirpichev deleted the format/7 branch July 8, 2025 06:35
@skirpichev skirpichev added this to the 0.4 milestone Feb 4, 2026
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.

Implement mpz.__format__()

1 participant