Register interpreter benchmarks from the python/ directory
Follows #1055, which moved the scripts into benches/python/ but kept each benchmark's expected value, inputs and variants in main.rs.
Now the scripts are plain Python and main.rs registers them by reading the directory: adding a .py file adds a benchmark, with no Rust change.
- Self-checking scripts. The last expression of each script became an
asserton its old expected value (assert len(v) == 77), so any Python implementation can run the file and fail loudly if the result is wrong. # bench:header for what Rust used to hard-code:data=<path>bindsDATAto a file's contents,mountbinds it to the mounted scan tree (overlayadds an overlay-mount variant),limitsadds a resource-limits variant. Unknown options panic.- Registered from the directory: every top-level
benches/python/*.py, plustest_cases/bench__*.py, so the kitchen sink stays shared with the datatest suite. Its# Return=373becameassert result == 373. - Names unchanged, so CodSpeed history carries over:
fib_25.pywas renamed tofib.pyto keepfib__monty. The same benchmarks register as before: 63 locally and 36 under thecodspeedfeature. - CPython now runs each compiled module at module scope, in fresh globals, as Monty does, replacing
wrap_for_cpython's text rewrite intodef main(). Module-scope variable access is slower in CPython than locals, so the local__cpythonnumbers will rise. The comparison is now like for like. - The
csv_read/csv_writebenchmarks from #1018 are converted too. Their CPython variants were gated oncfg(not(codspeed)), which walltime and memory builds never set, so they were running in CodSpeed CI. Every CPython benchmark is now gated on thecodspeedfeature. pool.rs's scripts moved topython/pool/, since they need a host to answer their calls.end_to_endnow parsesadd_two.py.
The Rust-API benchmarks (parse_1k_assigns, clone_module, repl_feed_after_2k_snippets, session_dump/load) stay in Rust, because their code is generated.
Checked: -- --test passes with and without the codspeed feature, a wrong expected value fails the benchmark with the script's traceback, and the bench__kitchen_sink datatest passes.
🤖 Generated with Claude Code
https://claude.ai/code/session_016t3CWLMcgDnRzncyejqP6T
Summary by cubic
Registers interpreter benchmarks by reading the benches/python/ directory, so adding a .py file adds a benchmark without a Rust change. Each script checks its own result with an assert.
The new monty-fixture crate parses a # /// monty PEP 723 block of TOML shared by test cases and benchmark scripts. The datatest harness's old # call-external-style markers became header keys. The block must sit in the file's leading comments, so a string or later comment can't configure a fixture, and a misspelled key, wrong type, or malformed block panics instead of silently dropping the setting, with errors naming the line the header opens on. The header stays in the code, so TRACEBACK line numbers in test cases were updated to count its lines.
- Scripts assert their own expected result; the old
# bench:options became the header's[bench]table (data,mount,overlay,limits), and non-[bench]keys are rejected. - Both interpreters receive the script's real file name, so tracebacks match the file.
DATAis bound in limits runs too, and onlyloop_mod_13keeps a limits variant now that the csv ones are dropped.- CPython runs each compiled module at module scope in fresh globals, matching Monty, so local
__cpythonnumbers will shift as module-scope variable access is slower than the oldmain()-wrapped locals. pool.rs's scripts moved topython/pool/so the directory scan doesn't pick them up as standalone benchmarks.