-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: BUG: review need for NpyIter_Close, add missing test for out #11370
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
Conversation
Can you remind me why you introduced NpyIter_Close() at all? Couldn't the cleanup always be done by Couldn't |
@@ -1112,6 +1112,7 @@ arr_ravel_multi_index(PyObject *self, PyObject *args, PyObject *kwds) | |||
Py_XDECREF(op[i]); | |||
} | |||
npy_free_cache_dim_obj(dimensions); | |||
/* no NpyIter_Close required since output is always allocated */ |
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.
Is there any reason not to just always call it? Testing a handful of flags should be pretty cheap, and if its not, you could cache them in the constructor?
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.
We store the need to resolve the writeback in a per-operand flag, so traversing those would be very cheap.
This PR is more to check if our testing is adequate, if there were places that are missing a needed NpyIter_Close
that would indicate missing tests. It seems that part is OK, barring mistakes.
When we discussed the design there was a need for
Edit: formatting |
Why can't we just call |
If we merge NpyIter_Dealloc and NpyIter_Close, npyiter_dealloc would need to warn if any operand flags have NPY_OP_ITFLAG_HAS_WRITEBACK. We should decide before the 1.15 release since NpyIter_Close is part of the public API. |
Doesn't it already do that if you don't call Just to be clear here:
|
There was some desire in the original discussion to allow re-entering the iterator:
If we call |
@ahaldane any thoughts? If we disallow the reentry, this seems like a nice cleanup. In any case, it seems we can remove |
There's no reason for this to be true - |
Found a way to raise the warning even if the iterator is reentrant in #11376 |
PR #11376 replaces this |
After reviewing all the places
NpyIter_Dealloc
is called withoutNpyIter_Close
, it seems the only case that can trigger the need to callNpyIter_Close
(reminder: that is needed when an operand has been created with theWRITEBACK_IF_COPY
flag) is in one of the compiled test modules.I left comments next to the calls to
NpyIter_Dealloc
as reminders and for reviewers.I also added a passing test for the
out
argument innp.busday_offset
, see issue #11369 about test coverage