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

Accessing memoryview base attribute uses Python attribute access #2577

Open
jakirkham opened this Issue Aug 24, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@jakirkham
Contributor

jakirkham commented Aug 24, 2018

Naively would think the following code would use some C level access pattern (e.g. using Py_buffer), but it appears to be generating Python attribute access code. Any ideas why?

cpdef object test(double[:] a):
    return a.base
@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Aug 24, 2018

Contributor

This is implemented as a Python property. Since it's really just passing through an internal object attribute, it could probably be changed to use that attribute directly. For that, the obj attribute would have to be renamed to base and be declared as readonly. Not sure if that's enough (and how much that breaks), but could be worth a try.

Contributor

scoder commented Aug 24, 2018

This is implemented as a Python property. Since it's really just passing through an internal object attribute, it could probably be changed to use that attribute directly. For that, the obj attribute would have to be renamed to base and be declared as readonly. Not sure if that's enough (and how much that breaks), but could be worth a try.

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Aug 24, 2018

Contributor

One drawback is that direct write access to that attribute would then be possible from Cython code. I know, we're all adults and all that, but still, I'm not sure that's a good idea …

Contributor

scoder commented Aug 24, 2018

One drawback is that direct write access to that attribute would then be possible from Cython code. I know, we're all adults and all that, but still, I'm not sure that's a good idea …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment