How to save numpy.ndarray in static or thread local variable in python extension written in Rust with PyO3?
I am building a simple python extension to process numpy.ndarray objects using rust-numpy crate. I want to save numpy.ndarray objects in static or thread local variables for later process:
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: