BUG: do not modify the input to ufunc_at#24272
Merged
seberg merged 2 commits intonumpy:mainfrom Jul 27, 2023
Merged
Conversation
seberg
approved these changes
Jul 27, 2023
Member
seberg
left a comment
There was a problem hiding this comment.
Thanks, this looks good!
Mid/Long-term, I would prefer the other solution. Especially if we can push the "within range" check into the same buffer filling step at least sometimes.
(That is a bit tricky since it would remove the promise of not mutating the input array if there is an out-of-bound index somewhere.)
Maybe that adds a bit of overhead to the main optimized (and most common) path. But I think it should allow to sanely merge the different branches at least partially. (i.e. we can fill a single offset/pointer buffer even for N-dimensional indexing.)
Member
|
Would be nice to cover those branches, but let's get this in for backporting, they all follow the same tested pattern after all. Thanks again. |
seberg
added a commit
to seberg/numpy
that referenced
this pull request
Jul 28, 2023
This is a follow-up to numpygh-24272 which missed a few files.
charris
pushed a commit
to charris/numpy
that referenced
this pull request
Jul 30, 2023
This is a follow-up to numpygh-24272 which missed a few files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@seberg pointed out that PR #24150 changes the input of the index argument when it has negative values. Instead, push the calculation down into the inner loop function. Another option would be to allocate a temporary buffer, but this solution avoids the allocation and removes the double-traversal of the indexes (once when preparing the arguments, once in the inner loop call).
This aligns the indexed inner loops with what is done in the other instances of this type of code, as shown at the top of #24150.