pyo3::prelude

Macro wrap_pyfunction

Source
macro_rules! wrap_pyfunction {
    ($function:path) => { ... };
    ($function:path, $py_or_module:expr) => { ... };
}
Expand description

Wraps a Rust function annotated with #[pyfunction].

This can be used with PyModule::add_function to add free functions to a PyModule - see its documentation for more information.

During the migration from the GIL Ref API to the Bound API, the return type of this macro will be either the &'py PyModule GIL Ref or Bound<'py, PyModule> according to the second argument.

For backwards compatibility, if the second argument is Python<'py> then the return type will be &'py PyModule GIL Ref. To get Bound<'py, PyModule>, use the crate::wrap_pyfunction_bound! macro instead.