Replies: 1 comment
-
|
To do parallelism at the Python level, your best option is probably to consider using Python 3.14's free-threaded build, see https://pyo3.rs/v0.26.0/free-threading.html (note 3.14 is in the final RC at present) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
async fn run_python_code(code: Arc, i: usize) -> PyResult<Py> {
Python::attach(|py| {
assert!(py.version_info() >= (3, 13));
let locals = PyDict::new(py);
py.run(code.as_c_str(), Some(&locals), Some(&locals))?;
Ok(locals.into())
})
}
code is
let input_fib = r#"
def fib(x):
if x == 0:
return 0
elif x == 1:
return 1
return fib(x-1) + fib(x-2)
_result = fib(25)
"#;
Whether running individually or in parallel, the total time remains the same. I think it's because of GIL, how can I make it run in parallel?
Beta Was this translation helpful? Give feedback.
All reactions