Skip to content

How to use Vec<MyPyClass> as parameter a of pyfunction? #2103

Discussion options

You must be logged in to vote

Have you tried Vec<Py<Foo>>? Py<T> is a pointer to a pyclass T managed by the Python heap. If the Python code passes e.g. a list of Foo to you, then this list will actually contain pointers to Foo instance on the heap.

Alternatively you can pass by value, e.g. Vec<Foo> if that makes sense w.r.t. the semantics of Foo, e.g. I think this requires Foo: Clone, i.e. adding #[derive(Clone)] to struct Foo.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tushushu
Comment options

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