-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
ENH: DType API slot for descriptor finalization before array creation #24988
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
3cf9b43
to
d22e73f
Compare
dc5f475
to
7528511
Compare
Updated the description and title to reflect the API discussed above. |
d095654
to
3d454ee
Compare
I think this is ready now - do you think the changes to |
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.
Yes, I think this is fine and happy to merge it. One error check missing. Since the take/indexing paths cannot have subarray dtypes, all is good there: in fact, it might fix bugs around S0
string dtypes which can be created in some places (although there may be a point that we should fix that in a lower way using the new hook :)).
3d454ee
to
a7aa6a3
Compare
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Thanks for giving this a look @seberg! Let's pull this in. |
This adds a new DType API slot,
NPY_DT_finalize_descr
that, when defined, numpy calls before creating a new array buffer and sets the dtype for the array to the return value.In addition to the change to
PyArray_NewFromDescr_Int
, this also includes two changes to the boolean subscripting internals andnpy_fasttake
, where numpy assumes that input and output dtypes are the same. These are separate bugfixes but were needed to get my stringdtype arena allocator implementation working (numpy/numpy-user-dtypes#92).