Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return views to C++ objects instead of copies #367

Open
adrien-berchet opened this issue Jan 10, 2022 · 5 comments
Open

Return views to C++ objects instead of copies #367

adrien-berchet opened this issue Jan 10, 2022 · 5 comments

Comments

@adrien-berchet
Copy link
Member

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: pybind/pybind11#2271 which would probably improve performance and reduce memory usage.

@mgeplf
Copy link
Contributor

mgeplf commented Jan 10, 2022

Which calls are you specifically thinking about?
IIRC, the immutable_morph::points and immutable_morph::section_offsets do a no copy version already.

@mgeplf
Copy link
Contributor

mgeplf commented Jan 10, 2022

(oops, just checked, section_offsets makes a copy - points looks right though)

@adrien-berchet
Copy link
Member Author

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?

@mgeplf
Copy link
Contributor

mgeplf commented Jan 10, 2022

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.

mgeplf added a commit that referenced this issue Jan 10, 2022
* fixes #367
* very gross; need to use pybind11::detail to be able to touch the flags
@eleftherioszisis
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants