MCPcopy Index your code
hub / github.com/RustPython/RustPython / cpy_compile_code

Function cpy_compile_code

benches/microbenchmarks.rs:96–108  ·  view source on GitHub ↗
(
    py: pyo3::Python<'a>,
    code: &str,
    name: &str,
)

Source from the content-addressed store, hash-verified

94}
95
96fn cpy_compile_code<'a>(
97 py: pyo3::Python<'a>,
98 code: &str,
99 name: &str,
100) -> pyo3::PyResult<pyo3::Bound<'a, pyo3::types::PyCode>> {
101 let builtins =
102 pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins");
103 let compile = builtins.getattr("compile").expect("no compile in builtins");
104 Ok(compile
105 .call1((code, name, "exec"))?
106 .cast_into()
107 .expect("compile() should return a code object"))
108}
109
110fn bench_rustpython_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchmark) {
111 let mut settings = Settings::default();

Callers 1

bench_cpython_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected