I want to write part of a python module in rust (with PYo3) but also partly in python, so something like...
src/utils.rs:
use pyo3::prelude::*;
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
#[pymodule]
fn nvm(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
}
src/main.py:
from .utils import sum_as_string
...
Mostly just curious if this is possible with pyo3 or if I have to write everything in rust, cuz I've seen something like this done with C/Cython (example).