Skip to content

Parallel run #[pyfunction] to get multi PyObject in Rust #3027

Answered by davidhewitt
sun-rs asked this question in Questions
Discussion options

You must be logged in to vote

You can't interact with Python objects from multiple threads, so you'll need to use a thread-safe datastructure to build the map. Perhaps hashbrown::HashMap with the hashbrown/rayon feature enabled. You can then use pyo3/hashbrown feature to enable conversion of hash brown::HashMap to PyDict once the multithreaded part is complete.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sun-rs
Comment options

@davidhewitt
Comment options

Answer selected by sun-rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants