Relative Content

Tag Archive for pythonrustpyo3

I can’t import converted rust code into origin python project while using pyo3

Now I am converting python project into rust using pyo3.
I am going to convert the core functions of the python custom module in this project into rust using pyo3 to improve the performance.
I converted the python code into rust, and build with maturin. But then I can’t integrate it with origin python code.
The main project runs on Docker, and the built code runs in the virtual environment.
So it’s impossible to import the converted rust code in the python code.
Anyone help me.
This is my project.
https://github.com/gentlepuck071/PyO3Project

How do I return a numpy array in rust using pyo3?

I am doing a python project that needs a bit of a speed boost, so I am making rust do a bit of the heavy lifting. What my project requires is that I can take in a numpy array, convert it to a rust array, apply some function to it, and return it as a numpy array. My only problem right now is specifying the lifetime of the return type (it is giving me the error “missing lifetime specifier
this function’s return type contains a borrowed value, but the signature does not say whether it is borrowed from py or array” under this bit of code: