Replies: 1 comment 3 replies
-
You cannot pass types containing generics or lifetimes to Python as these concepts are alien to the language, hence an iterator exposed to Python needs (shared) ownership of the data it iterates. (This is basically the same as if the iterator was implemented in Python itself which would also keep references to the underlying data structure around.) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So I have had a brief discussion on rust forum regarding a sensible way to return rust iterators in python.
https://users.rust-lang.org/t/how-do-i-return-rust-iterator-from-a-python-module-function-using-pyo3/89306
What remains unanswered is what's a proper way to return non-trivial rust iterators in python using pyo3! We can't always consume all of iterator before returning it to python. That's not practical for any non-trivial use case!
Please see the discussion on the rust forum. Let me know if I need to elaborate here again.
Beta Was this translation helpful? Give feedback.
All reactions