As soon as my python module calls a rust function, it exits without any output and ignores try/except blocks. My code is something like this:
python:
def call_rust(some_bytes: bytes):
print("debug")
val = rust_function(some_bytes)
…
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 {
Ok((a +…
I am currently trying to speedup a python scientific code with the help of PyO3. Until now, numba's @jit has been doing wonders, but some routines are impossible to parallelize.
I decided to turn to Rust and Rayon which provide the tools to…
I'm new to pyo3 and a beginner in Rust. What I'm trying to do is to return from Rust slice to Python bytes. I read both about the type conversion and memory management in the pyo3 documentation, but I still feel a bit lost.
This is what I have right…
I'm working on a rust/python package using PyO3 and its working great from python after I run maturin develop. I can import my rust code into Python and run my functions as I expect.
I would also like to still run my code from Rust though, and so…
I have created a custom module in rust and converted it to a python module using PyO3 binding. It works on a local machine using the hardcoded route, unlike other packages where it only has a name. I understand other packages are launched in PIP…
I have a method foo with the following signature:
pub fn foo(data: PyReadonlyArrayDyn) {
...
}
In my test I'm trying to create a test array to feed into foo
pyo3::Python::with_gil(|py| {
let vec = vec![1.0, 2.0, 3.0, 4.0];
py_array…
I have a pre-imported module that I'm calling a method with python gil, something like the following.
Python::with_gil(|py| {
let res = module.call_method1(py, "my_method", (arg1, arg2))?;
})
This returns the rust object PyObject, however what…
All the other questions on this forum tell you how to use rust to do something in python, but I want to do the opposite.
I have a function in my main.py script that reads the user's input and stores it. I want to pass that information to a rust file…
I am trying to generate Rust bindings for Python. Here is a simple example:
use pyo3::prelude::*;
struct MyClass {
num: T,
}
impl MyClass {
fn new(num: T) -> Self {
MyClass { num }
}
}
/// A Python…
I am trying to execute a python async function in an actix web socket.
I was able to figure out how to execute a sync function and send the response back to the web socket. However, I am unable to do the same with the async functions.
Here is my…
I'm writing a game in Rust where each player can submit some python scripts to the server in order to automate various tasks in the game. I plan on using pyo3 to run the python from rust.
However, I can see an issue arising if a player submits a…
I'm able to expose simple functions written in Rust to python using pyo3 but can see no way to expose complex "eigen" / matrix types. Does anyone know if this is possible?
lib.rs
extern crate nalgebra as na;
use pyo3::prelude::*;
use…
I'm trying to create a client using Rust and its Tokio runtime, and bind it to python using pyo3 and pyo3-asyncio. To bring this into a minimal example, let's say I want to have a Client class that connects to 127.0.0.1:1234 and has an echo method…