MorphIO
MorphIO copied to clipboard
Return views to C++ objects instead of copies
As far as I can see, the Python bindings of the functions and methods of MorphIO return copies of C++ data instead of views to these data. It seems possible to return views: https://github.com/pybind/pybind11/issues/2271 which would probably improve performance and reduce memory usage.
Which calls are you specifically thinking about?
IIRC, the immutable_morph::points
and immutable_morph::section_offsets
do a no copy version already.
(oops, just checked, section_offsets
makes a copy - points
looks right though)
As far as I can remember, #359 was done because the points
method returns a copy. @eleftherioszisis did some tests to show that it is actually a copy, I don't know if he still has them?
Very good point, we'll look into it.
One thing we have to be careful about is making sure that the python bindings aren't a backdoor
to modifying the morphology.
I have made an attempt to build on top of Mike's initial implementation in #373 . The lifetimes, refcounts, etc. all seem to work except for the Vasculature's last section, which seems to exhibit an issue with its refcount.