rust-pyo3: getting rust-cpython GIL handle from various PyO3 objects...
rust-pyo3: getting rust-cpython GIL handle from various PyO3 objects
Depending on the caller context, we might have a `Python<'py>`
around or any of the smart pointers that bear the GIL lifetime.
Of course, all of these can give back a `Python<'py>` but it is
worthwile to reduce the needed boilerplate.
The trait just expresses that a lifetime is assumed to be outlived
by the PyO3 GIL lifetime. It is marked as unsafe because that is
just trusting the implementor.
A first version of this was made of a safe trait with a `get_py()` method
and the corresponding trivial implementations. We found it finally to be
even more artificial, as it boils down to coding 4 functions
doing and returning no real data, that we hope the compiler
will optimize away.