ENH: Refactor deallocation of dtypes with embedded references #22692
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.
Draft for now, since I want to discuss the approach a bit (I have two).
Basically, this changes it so that we use a
clearfunction for each DType rather than the current "specialized"PyArray_Decref, which cannot be extended to non-objects.We already have functions to clear buffers internally in the casting machinery, so this wires them in. There are two very unrelated questions:
Should we even bother keeping
PyArray_Decref()in case someone wants to decref without also clearing? I would still prefer deprecating it, I think. But maybe we should first expose the new API... Unless we can just rename the symbol.I have two different approaches to do this:
ArrayMethodwhich is very simple because it fits with our casting setup. But we don't needresolve_dtypesand need to pass a lot of indirections (there is 1 array to operate, so we only need 1 stride, data pointer, etc.)TRAVERSEslot, which I presume we need eventually.(For some Python implementations, I believe you must have a traverse).