4 ms·
How does this interact with Rust memory safety? I am not familiar with the PyToObject trait, so I am guessing that this has some kind of safety wrapper?
by dbcurtis 8y ago
How does this interact with Rust memory safety? I am not familiar with the PyToObject trait, so I am guessing that this has some kind of safety wrapper?
- m-ou-se 8y agoIn Python, all data (even simple integers) are all allocated on the heap. ToPyObject makes a deep copy of everything, converting everything to `PyObject` on the heap, so all data is owned. The numpy crate helps if you need to convert large arrays to Python, as numpy does not store every element separately on the heap.
- maccard 8y ago> In Python, all data (even simple integers) are all allocated on the heap. Total sidebar, this leads to one of my favourite programming language "quirks" - you can redefine the value of 1! http://hforsten.com/redefining-the-number-2-in-python.html http://hforsten.com/redefining-the-number-2-in-python.html