3 ms·
Edit: Yes it does, as ynik rightly points out, and documented here https://pyo3.rs/v0.19.2/types#gil-lifetimes-mutability-and-python-object-types https://pyo3.r
by guitarbill 3y ago
Edit: Yes it does, as ynik rightly points out, and documented here https://pyo3.rs/v0.19.2/types#gil-lifetimes-mutability-and-python-object-types https://pyo3.rs/v0.19.2/types#gil-lifetimes-mutability-and-p... or here https://docs.rs/pyo3/0.19.2/pyo3/marker/struct.Python.html#obtaining-a-python-token https://docs.rs/pyo3/0.19.2/pyo3/marker/struct.Python.html#o...
- ynik 3y agoThe Python<'_> type appearing as a parameter means the caller has already acquired the GIL for you. The GIL is held when Python calls into extension modules, and PyO3 doesn't automatically release it (but you can do so yourself). It's essentially a dummy parameter that serves as proof that the GIL is held. You need to provide it to PyO3 when calling back into the Python runtime, that way the compiler ensures the GIL is still held where required.