-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: make ufunc.at faster for more cases #23176
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
Another thing that I would find absolutely amazing is if we could make "indexed" ufunc loops and advanced indexing be basically the same thing (i.e. reuse this machinery there). I do feel that should be plausible. Some more ideas of how things might be munched generally:
|
More suggestions:
|
Also speed up the case where the values are scalar (currently, 1D single element is fast, but array scalar is not):
(Also not sure where the overflow warning comes from!) |
Maybe not obvious from the examples, but the "fastest" optimization only kick in when
The overflow in addition is suspicious: |
To be fair, you could generalize it to 0-D. We probably should do that, it seems rather surprising that 0-D is slow there. The stride is just 0 then. No casting is harder to eliminate of course.
This is a pretty serious bug (oddly quiet it would be nicer if it just crashed)! And we need to fix it. The problem is that we do allow broadcasting of values to the index, but that doesn't work out here (it could, but we would have to set the stride to 0). |
PR #23136 and #22889 created fast paths through
ufunc.at
for 1d aligned arrays with no casting. I closed issues #11156, #7998, #5922, and #8495, as mentioned in this comment and opened this to continue the discussion around additional speedups and concerns:bincount
is faster thanufunc.add.at
?bincount
.ufunc.at
does not support theaxis
kwarg, so I left that issue open.The text was updated successfully, but these errors were encountered: