-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
MAINT: Remove dead codepath in generalized ufuncs #18864
Conversation
@@ -2457,7 +2457,7 @@ PyUFunc_GeneralizedFunctionInternal(PyUFuncObject *ufunc, PyArrayObject **op, | |||
/* Fill in any allocated outputs */ | |||
{ | |||
PyArrayObject **operands = NpyIter_GetOperandArray(iter); | |||
for (i = 0; i < nop; ++i) { | |||
for (i = nin; i < nop; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point in iterating through all, op[i]
cannot be NULL unless i >= nin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, this could be moved into the later loop, but for clarity, I wasn't sure that would actually be better...
Added a test for the (non-) possibility of an output that is broadcast. I am not 100% sure that it isn't possible to override the iterator flags in weird ways to allow a broadcast here, but I think I will put that into the realm of "doesn't really make sense" until proven otherwise. |
a0ec427
to
7f6a1c2
Compare
If the iterator has size zero, then that means that the outer iteration has size. Since the outer iteration is unaffected by core dimensions, in that case the output always has size zero and the code does nothing but unnecessary checking the array sizes.
This ensures that it is correct to not initize the output array if the outer iteration has size 0. The broadcast result would always have size 0 in that case. If the iterator rejects such a broadcast it cannot happen.
7f6a1c2
to
18ffb74
Compare
Thanks @seberg |
If the iterator has size zero, then that means that the outer
iteration has size. Since the outer iteration is unaffected by
core dimensions, in that case the output always has size zero
and the code does nothing but unnecessary checking the array sizes.
@rossbar this is a short PR you will like ;).