这是indexloc提供的服务,不要输入任何密码
Skip to content

API: Remove PyArray_GetCastFunc and any guarantee that ->castfuncs are defined #25161

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

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

seberg
Copy link
Member

@seberg seberg commented Nov 16, 2023

NumPy never used them internally, in two places, we did expose access to these functions indirectly. (In these places use the cast function also used in PyArray_Pack().)

We still do support the use for custom legacy dtype and some casts were never ported to the newer machinery, thus, those need to remain.

The second commit tries to remove all cast functions we do not use internally.


I think we need to delete this, pandas has one useless occurrence of this. If anyone complains or has doubts, I would be happy to introduce a PyArray_CastContiguous(...) (or even PyArray_CastBuffer which is strided) with a backport implementation that keeps using these on old versions (because fetching the real one needs a bit of magic).


Cleaning out arraytypes.c.src to not include the unnecessary versions is unfortunately a bit of a mess/reorg :(.

@seberg seberg added this to the 2.0.0 release milestone Nov 17, 2023
@ngoldbaum
Copy link
Member

ngoldbaum commented Nov 28, 2023

I need to stare really hard at the arraytypes.c.src changes but am planning to do that this week to keep the C API changes moving forward. I'll ping you on slack if I get confused...

@ngoldbaum
Copy link
Member

The arraytypes cleanup is really nice! I just saw one place where I think there's a reference counting bug but otherwise I think is good to go.

return 0;
void *src = scalar_value(scalar, indescr);
if (src == NULL) {
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decref out_dt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch thanks. Fixed it also in the other one, where I did the same error.

We still support legacy user DTypes to use this functions and also
still use a few of them internally.
However, this removes any non-explicit use form our API
(i.e. any remaining use is because we know that there is no modern
cast implementation.)
@ngoldbaum
Copy link
Member

The Mac arm64 failure looks like some kind of unrelated SIMD or BLAS bug.

I think this is unlikely to get more detailed reviews soon and this is a very nice cleanup of a bunch of legacy stuff. Let's pull this in now.

@ngoldbaum ngoldbaum merged commit 198f339 into numpy:main Dec 1, 2023
@seberg seberg deleted the remove-cast branch December 1, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants