Skip to content

How can I do an advanced management of PyModules #2080

Discussion options

You must be logged in to vote

I think you want:

#[pyfunction]
fn empty_module<'py> (py: Python<'py>) -> PyResult<&'py PyModule> {

and

#[pyfunction]
fn import_view<'py>(
    py: Python<'py>,
    name: &str,
    dependencies: Vec<&PyModule>,
    code: &str,
) -> PyResult<&'py PyModule> {

You can always take Python as an argument to the #[pyfunction] - this argument doesn't really exist on the Python side, and PyO3 will fill it in for you.

For get_gil, perhaps taking py: Python removes the need for it?

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@jmwielandt
Comment options

@davidhewitt
Comment options

@jmwielandt
Comment options

@davidhewitt
Comment options

Answer selected by jmwielandt
Comment options

You must be logged in to vote
1 reply
@jmwielandt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants