rust

Exporting HashMap of HashMap to Python

Exporting HashMap of HashMap to Python Question: I have a text parser written in Rust and want to provide a Python interface to it using pyo3. The parser returns a HashMap within a HashMap and the values of the inner HashMap are of type serde_json::Value. When I try to return this as a PyObject I …

Total answers: 1

Return reference to member field in PyO3

Return reference to member field in PyO3 Question: Suppose I have a Rust struct like this struct X{…} struct Y{ x:X } I’d like to be able to write python code that accesses X through Y y = Y() y.x.some_method() What would be the best way to implement it in PyO3? Currently I made two …

Total answers: 2

Running Python code in parallel from Rust with rust-cpython

Running Python code in parallel from Rust with rust-cpython Question: I’m trying to speed up a data pipeline using Rust. The pipeline contains bits of Python code that I don’t want to modify, so I’m trying to run them as-is from Rust using rust-cpython and multiple threads. However, the performance is not what I expected, …

Total answers: 2

In Rust, what is the proper way to replicate Python's "repeat" parameter in itertools.product?

In Rust, what is the proper way to replicate Python's "repeat" parameter in itertools.product? Question: In Python, I can do: from itertools import product k = 3 for kmer in product(“AGTC”, repeat=k): print(kmer) In Rust, I can force the behavior of k=3 by: #[macro_use] extern crate itertools; for kmer in iproduct!(“AGTC”.chars(), “AGTC”.chars(), “AGTC”.chars()){ println!(“{:?}”, kmer); …

Total answers: 2

Dylib built on CI can't be loaded

Dylib built on CI can't be loaded Question: I’m building a Rust binary (liblonlat_bng.dylib) on Travis CI, pulling it into a Cython extension (in the same dir as the Cython source .c/.pyx), and testing it, also on Travis CI (in a different repo and build). However, tests of the Python package are failing, and I’m …

Total answers: 2