Skip to content

Conversation

ngoldbaum
Copy link
Member

@ngoldbaum ngoldbaum commented Oct 23, 2023

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 and npy_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).

@ngoldbaum ngoldbaum marked this pull request as draft October 27, 2023 15:20
@ngoldbaum ngoldbaum changed the title ENH: DType flag for unique per-array descriptors ENH: DType API slot for descriptor finalization before array creation Oct 30, 2023
@ngoldbaum ngoldbaum marked this pull request as ready for review October 30, 2023 21:22
@ngoldbaum
Copy link
Member Author

Updated the description and title to reflect the API discussed above.

@ngoldbaum ngoldbaum force-pushed the unique-array-descr branch 3 times, most recently from d095654 to 3d454ee Compare October 31, 2023 14:55
@ngoldbaum
Copy link
Member Author

I think this is ready now - do you think the changes to fasttake and the boolean subscripting internals look OK too?

Copy link
Member

@seberg seberg left a 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 :)).

Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
@ngoldbaum
Copy link
Member Author

Thanks for giving this a look @seberg! Let's pull this in.

@ngoldbaum ngoldbaum merged commit 42c33f3 into numpy:main Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants