I have a Rust library using PyO3, and one of my functions looks like this:
#[pyfunction]
pub fn my_func<'a>(py: Python<'a>) -> PyResult<&'a PyBytes> {
let my_data: Vec = do_stuff(); // very large data here, >1GB
let result =…
I'm attempting to open and write to a database in a Rust library I will call from python, with the help of pyo3. If an error occurs, I would like to raise an exception that can be caught in the calling Python process, but I'm having difficulties…
I have a library that I've created with PyO3 on my system using Python 3.5.2. The .so file links to the corresponding libpython3.5m file:
$ ldd my_library.so
linux-vdso.so.1 => (0x00007ffffc823000)
libpython3.5m.so.1.0 =>…
I'm trying to inline Python code in Rust, but it fails when the Python code has the operator for floor division // which is ignored as if it were a Rust comment.
For instance:
#![feature(proc_macro_hygiene)]
use inline_python::python;
fn main() {
…
I have some class A that is part of a Python extension I wrote in Rust using PyO3. class A is imported and used as is, as well as being as being subclassed in my Python code as part of a larger Python package. It's not meant to be an independent…
I am struggling to get kwargs to work. I understand that just like #[args(args="*")] is for args, #[args(kwargs="**")] is for kwargs.
However when I pack the following using pyo3-pack and try to call test1 with any arguments I get the error…
I want to implement a system which consists of a Python UI and some Rust datastore and functions.
The user executes the python code which in turn executes the Rust program in a subprocess.
I want the Rust program to run in the background, waiting…
I want a function that simply creates and returns a tuple as an example.
Basic template starting code (maturin new) looks like:
use pyo3::prelude::*;
/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize)…
Is this possible?
After some research, it seems that the library setuptools-rust can be used for easy distribution, but it looks like the user also needs this library setuptools-rust.
Is there any way to make the installation work without…
I created 2 files that have the same function. One is named test1.py and the other test2.py. I try to import test1 that imports test2. Rust throws this error. How can i import relative paths. Id prefer not to change the python code, since i want to…
In the __enter__ method I want to return an object which is accessible in Rust and Python, so that Rust is able to update values in the object and Python can read the updated values.
I would like to have something like…