-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Bound checks in numpy array accessors #584
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
Comments
Which access methods are you most interested in, do you have a minimal example? In a loop, you have unchecked version of |
I think that all the access methods should be like this on the c++ side (except for I opened this in a separate issue from the original PR hoping that you would reconsider. The unchecked version are only a few assembly instructions which makes looping worth considering. |
Closing this since unchecked access is now provided. |
The current behavior of data access methods in
py::array
andpy::array_t
is to check the dimension bounds every time the accessor is called, via thecheck_dimensions
function, event when using it in a loop.I agree that when exposing a feature to Python, it must be written in such a way that regardless of the values passed to it, it cannot crash the interpreter, but these accessors are not directly exposed to the Python users. Instead, I think that one of the main reasons people would right c++ extensions with pybind is because they want speed, and they might be disappointed with this behavior. #500 already improved the situation, but as we discussed there, I would prefer to completely remove the bound checking.
The text was updated successfully, but these errors were encountered: