-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
PERF: improve StringArray.isna #57733
base: main
Are you sure you want to change the base?
PERF: improve StringArray.isna #57733
Conversation
cnp.PyArray_ITER_NEXT(it) | ||
if val is C_NA: | ||
# Dereference pointer (set value) | ||
(<uint8_t *>(cnp.PyArray_ITER_DATA(it2)))[0] = <uint8_t>1 |
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.
You can just assign 1U - no need for the cast on the right hand side
@@ -220,6 +220,51 @@ cpdef ndarray[uint8_t] isnaobj(ndarray arr): | |||
return result.view(np.bool_) | |||
|
|||
|
|||
@cython.wraparound(False) | |||
@cython.boundscheck(False) | |||
cpdef ndarray[uint8_t] isna_string(ndarray arr): |
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.
Can we return a const uint8_t memory view instead of an ndarray? I still think generally better to use memoryviews over the long term to stay somewhat backend agnostic
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.
I think for the return value we want a numpy array? (inside the function we could use more memoryviews)
I am actually only using this function from python, so can make this a def
function and remove the return type
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
See #57431 (comment) for context.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Speed-up is around 2x for this case (extracted from one of our ASVs):
Not entirely sure it is worth the extra code, but so it definitely gives a decent speedup for a common operation.