diff --git a/doc/benchmarks.rst b/doc/benchmarks.rst index 0ba6ebd8..bd0515bf 100644 --- a/doc/benchmarks.rst +++ b/doc/benchmarks.rst @@ -169,6 +169,26 @@ See `pyaes `_: A pure-Python implementation of the AES block cipher algorithm and the common modes of operation (CBC, CFB, CTR, ECB and OFB). +decimal_factorial +----------------- + +Compute ``10000!`` and ``100000!`` exactly with the ``decimal`` module, using +binary splitting. + +This benchmark is skipped on PyPy, where the pure-Python ``decimal`` module +hangs at this precision (see `pypy/pypy#5814 +`_). + +decimal_pi +---------- + +Compute ``pi`` with the ``decimal`` module at context precisions of 9 and 19 +digits. + +This measures the speed of many operations on small ``Decimal`` values. +See also the ``pidigits`` benchmark, which does a similar computation +with ``int``. + deepcopy -------- diff --git a/doc/changelog.rst b/doc/changelog.rst index 96448214..72249bc4 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -19,6 +19,9 @@ Version 2.0.0 (unreleased) and its results are mostly noise * Fix benchmark selection checking Python version requirements against the running interpreter instead of the target specified by ``--python`` +* Enable the ``decimal_factorial`` and ``decimal_pi`` benchmarks, which were + added in 1.12.0 but never listed in the manifest. ``decimal_factorial`` is + skipped on PyPy. Version 1.14.0 (2026-02-07) --------------------------- diff --git a/pyperformance/data-files/benchmarks/MANIFEST b/pyperformance/data-files/benchmarks/MANIFEST index 1af2a6a0..6d25e408 100644 --- a/pyperformance/data-files/benchmarks/MANIFEST +++ b/pyperformance/data-files/benchmarks/MANIFEST @@ -39,6 +39,8 @@ chaos comprehensions crypto_pyaes dask +decimal_factorial +decimal_pi deepcopy deltablue django_template diff --git a/pyperformance/data-files/benchmarks/bm_decimal_factorial/pyproject.toml b/pyperformance/data-files/benchmarks/bm_decimal_factorial/pyproject.toml index a6ece1c5..e4ee9803 100644 --- a/pyperformance/data-files/benchmarks/bm_decimal_factorial/pyproject.toml +++ b/pyperformance/data-files/benchmarks/bm_decimal_factorial/pyproject.toml @@ -8,3 +8,4 @@ dynamic = ["version"] [tool.pyperformance] name = "decimal_factorial" tags = "decimal" +unsupported_implementations = ["pypy"] # pypy/pypy#5814 diff --git a/pyperformance/data-files/benchmarks/bm_decimal_factorial/run_benchmark.py b/pyperformance/data-files/benchmarks/bm_decimal_factorial/run_benchmark.py index dceba16b..2ce18c51 100644 --- a/pyperformance/data-files/benchmarks/bm_decimal_factorial/run_benchmark.py +++ b/pyperformance/data-files/benchmarks/bm_decimal_factorial/run_benchmark.py @@ -4,6 +4,7 @@ - 2024-06-14: Michael Droettboom copied this from Modules/_decimal/tests/bench.py in the CPython source and adapted to use pyperf. +- 2026-12-01: Sergey B Kirpichev, use sys.set_int_max_str_digits(0). """ # Original copyright notice in CPython source: @@ -15,6 +16,7 @@ import decimal +import sys import pyperf @@ -38,11 +40,12 @@ def bench_decimal_factorial(): c.Emin = decimal.MIN_EMIN for n in [10000, 100000]: - # C version of decimal _ = factorial(decimal.Decimal(n), 0) if __name__ == "__main__": + sys.set_int_max_str_digits(0) + runner = pyperf.Runner() runner.metadata["description"] = "decimal_factorial benchmark"