Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: optimize algos.take for repeated calls #39692
PERF: optimize algos.take for repeated calls #39692
Changes from 8 commits
4512f9c
36c3ed2
6d52932
ded773a
2ee2543
f489ba5
96305c5
480d2b4
c70ac4d
9fba887
5273cd5
d3dd4e4
288c6f2
06a3901
ca30487
bf598a7
05b6b87
2284813
4861fdb
a41ee6b
b52e1ec
76371cf
2faf70b
1c19732
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
why is the caching not on this function? having too many levels of indirection is -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.
I will clarify the comment above, the
mask_info
argument to this function is not hashableThere 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.
this is very strange to do. can you simply change all of the call of
_maybe_promote
to_maybe_promote_cached
that need it (e.g. in the code and not the tests).putting a try/except inside here is reversing the paradigm and not good.
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.
That is not simply possible. We don't know in advance if the fill_value is going to be hashable or not. So that's the reason the fallback is needed.
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.
sure but the try/except needs to be in the cached method, NOT here. IOW you are now exposing 2 api's, we need to have exactly one.
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.
But try/except is because of non-hashable fill_values, which thus cannot be inside the cached method, that's the whole reason I added the try/except in the first place.
I am not exposing two different APIs. These are internal helper methods, and
_maybe_promote_cached
is only used for_maybe_promote
, and it is_maybe_promote
that is then used internally in thetake
implementation.I can add a comment to
_maybe_promote_cached
that this is only the cached part of_maybe_promote
and not to be used elsewhere.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 just simply ban non-hashables from
_maybe_promote
?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 you add these assertions