Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "pyperformance_bm_pickle_opt"
requires-python = ">=3.8"
dependencies = ["pyperf"]
urls = {repository = "https://github.com/python/pyperformance"}
dynamic = ["version"]

[tool.pyperformance]
name = "pickle_opt"
28 changes: 28 additions & 0 deletions pyperformance/data-files/benchmarks/bm_pickle_opt/run_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""The background for this benchmark is that the garbage collection in
Python 3.14.0 had a performance regression, see

* https://github.com/python/cpython/issues/140175
* https://github.com/python/cpython/issues/139951

"""

import pickle
import pickletools
import pyperf


def setup(N: int) -> bytes:
x = {i: f"ii{i:>07}" for i in range(N)}
return pickle.dumps(x, protocol=4)


def run(p: bytes) -> None:
pickletools.optimize(p)


if __name__ == "__main__":
runner = pyperf.Runner()
runner.metadata["description"] = "Pickletools optimize"
N = 100_000
payload = setup(N)
runner.bench_func("pickle_opt", run, payload)
Loading