Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
pyfunction in pyo3_macros - Rust
[go: Go Back, main page]

pyo3_macros

Attribute Macro pyfunction

Source
#[pyfunction]
Expand description

A proc macro used to expose Rust functions to Python.

Functions annotated with #[pyfunction] can also be annotated with the following #[pyo3] options:

AnnotationDescription
#[pyo3(name = "...")]Defines the name of the function in Python.
#[pyo3(text_signature = "...")]Defines the __text_signature__ attribute of the function in Python.
#[pyo3(pass_module)]Passes the module containing the function as a &PyModule first argument to the function.

For more on exposing functions see the function section of the guide.

Due to technical limitations on how #[pyfunction] is implemented, a function marked #[pyfunction] cannot have a module with the same name in the same scope. (The #[pyfunction] implementation generates a hidden module with the same name containing metadata about the function, which is used by wrap_pyfunction!).