Ben Brown
banner
benbrown.dev
Ben Brown
@benbrown.dev
PyO3 doesn't support sub-interpreters yet, so they're not straightforward to use from Rust. But you can use their FFI bindings for access.

pyo3.rs/main/doc/pyo...
pyo3::ffi - Rust
Raw FFI declarations for Python’s C API.
pyo3.rs
December 1, 2024 at 12:17 PM
From Python 3.12 you can create sub-interpreters with their own GILs (so they can execute concurrently) using the C API.

Most Python modules work well, but most extension modules (C API Modules) don't support multiple GILs yet.

docs.python.org/3/c-api/init...
Initialization, Finalization, and Threads
See Python Initialization Configuration for details on how to configure the interpreter prior to initialization. Before Python Initialization: In an application embedding Python, the Py_Initialize(...
docs.python.org
December 1, 2024 at 12:17 PM