-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
BUG: Fix searchsorted and CheckFromAny byte-swapping logic #28418
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
This closes numpygh-28190 and fixes another issue in the initial code that triggered the regression. Note that we may still want to avoid this, since this does lead to constructing (view compatible) structured dtypes unnecessarily here. It would also compactify the dtype. For building unnecessary dtypes, the better solution may be to just introduce a "canonical" flag to the dtypes (now that we have the space).
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.
Wow. The simplification in item_selection
is worth it even if there hadn't been a bug!
Inline some suggestions that may help clarity.
/* refs to dtype we own = 1 */ | ||
Py_INCREF(dtype); | ||
/* refs to dtype we own = 2 */ | ||
/* need ap2 as contiguous array and of right dtype (steals and may be replace it) */ |
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.
replace it
-> replace dtype
(since "it" could also refer to ap2
, the array).
Actually, with my comment below, I think this can just be
/* need ap2 as contiguous array and of right dtype (note: steals dtype reference) */
return NULL; | ||
} | ||
/* dtype was stolen, replace it in case the array creation replaced it. */ |
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.
Combine with l.2162? And write there,
/*
* The dtype reference we had was used for creating ap2, which may have
* replaced it with another. So here we copy the dtype of ap2 and use it for `ap1`.
*/
dtype = (PyArray_Descr *)Py_NewRef(PyArray_DESCR(ap2));
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.
Looks all good to me, although still a small query of the just-in-case variety.
Might as well get this in, I think! |
This closes gh-28190 and fixes another issue in the initial code that triggered the regression.
Note that we may still want to avoid this, since this does lead to constructing (view compatible) structured dtypes unnecessarily here.
It would also compactify the dtype. For building unnecessary dtypes, the better solution may be to just introduce a "canonical" flag to the dtypes (now that we have the space).
Actually, the bug may be going back to when the
_int
version was added (and started using borrowed references rather than stealing). Somehow, it seems we got away with that for a suprisingly long time.