Return dictionary from Rust to Python #3078
-
In |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There are two answers to this: The replacement for However, for |
Beta Was this translation helpful? Give feedback.
-
This is perfect, thanks so much! |
Beta Was this translation helpful? Give feedback.
There are two answers to this: The replacement for
Python::acquire_gil
isPython::with_gil
which serves the same purpose using a slightly different API (that is easier for us to implement soundly).However, for
#[pyfunction]
s and#[pymethod]
s, you can just add a parameterpy: Python<'_>
to get access to the GIL (which is already acquired when such a method is called). Put differently,Python::with_gil
is only necessary outside of such Python-visible functions and methods, for example to acquire the GIL on a background thread.