Pass List from Python to Rust without cloning elements #2037
-
Is there a good way to receive a Python I've tried receiving a list and extracting each element, but the #[classmethod]
fn cat(_cls: &PyType, buffers: &PyList, dim: usize) -> PyResult<Self> {
let mut bufs = Vec::new();
for buf in buffers.iter() {
bufs.push(&buf.extract::<&RaggedBufferF32>()?.0);
}
Ok(RaggedBufferF32(RaggedBuffer::cat(&bufs, dim)?))
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You can extract a |
Beta Was this translation helpful? Give feedback.
-
Yes, it doesn't matter too much in my case. With the current interface, you do need the second |
Beta Was this translation helpful? Give feedback.
You can extract a
&PyCell<RaggedBufferF32>
andborrow
it to get a&RaggedBufferF32
.