Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions doc/benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ See `pyaes <https://github.com/ricmoo/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
<https://github.com/pypy/pypy/issues/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
--------

Expand Down
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---------------------------
Expand Down
2 changes: 2 additions & 0 deletions pyperformance/data-files/benchmarks/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ chaos <local>
comprehensions <local>
crypto_pyaes <local>
dask <local>
decimal_factorial <local>
decimal_pi <local>
deepcopy <local>
deltablue <local>
django_template <local>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dynamic = ["version"]
[tool.pyperformance]
name = "decimal_factorial"
tags = "decimal"
unsupported_implementations = ["pypy"] # pypy/pypy#5814
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -15,6 +16,7 @@


import decimal
import sys


import pyperf
Expand All @@ -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"

Expand Down