Use stdlib native modules in benchmarks (#6792)

Change benchmark interpreter from without_stdlib to with_init to load
Rust-optimized native modules like _json, ensuring benchmarks measure
actual optimized performance rather than pure Python fallbacks.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lee DogeonandClaude Opus 4.5 authored and GitHub committed 2026-01-19 08:43:25 +09:00
1 parent 00440b179a
commit 4ab6a45405
2 files changed
+5 -1

No files matched your search

+1
View File
@@ -54,6 +54,7 @@ rustyline = { workspace = true }
[dev-dependencies]
criterion = { workspace = true }
pyo3 = { version = "0.27", features = ["auto-initialize"] }
rustpython-stdlib = { workspace = true }
[[bench]]
name = "execution"
+4 -1
View File
@@ -24,7 +24,10 @@ fn bench_rustpython_code(b: &mut Bencher, name: &str, source: &str) {
settings.path_list.push("Lib/".to_string());
settings.write_bytecode = false;
settings.user_site_directory = false;
Interpreter::without_stdlib(settings).enter(|vm| {
Interpreter::with_init(settings, |vm| {
vm.add_native_modules(rustpython_stdlib::get_module_inits());
})
.enter(|vm| {
// Note: bench_cpython is both compiling and executing the code.
// As such we compile the code in the benchmark loop as well.
b.iter(|| {