-
Notifications
You must be signed in to change notification settings - Fork 48
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
rm function.replace, add deep and shallow variants #863
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4292e07
to
5d6cbca
Compare
0fcf4ea
to
7e2006e
Compare
7e2006e
to
8f1bd08
Compare
joostvanzwieten
previously approved these changes
Mar 21, 2024
8f1bd08
to
4f13590
Compare
joostvanzwieten
approved these changes
Mar 21, 2024
This patch adds the deep_replace_property and shallow_replace decorators to _util. The differences between the two constructs are as follows: @_util.deep_replace_property - property - intermediate values cached in object attribute - depth first - recursive @_util.shallow_replace - function - intermediate values cached only during replacement - depth last - non recursive
This patch removes the function.replace decorator and replaces it with _util.deep_replace_property (for simplified and optimized_for_numpy) and _util.shallow_replace (for replace_arguments, _deep_flatten_constants and _combine_loop_concatenates). The specialized variants are faster, use less memory, and offer better cache reuse.
4f13590
to
507f0d6
Compare
2444961
gertjanvanzwieten
pushed a commit
that referenced
this pull request
Mar 21, 2024
This PR removes the general function.replace decorator and replaces it with the specialized deep_replace_property (used for simplified and optimized_for_numpy) and shallow_replace (used for replace_arguments, _deep_flatten_constants and _combine_loop_concatenates). The differences between the two constructs are as follows: @deep_replace_property - property - intermediate values cached in object attribute - depth first - recursive @shallow_replace - function - intermediate values cached only during replacement - depth last - non recursive
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR removes the general
function.replace decorator
and replaces it with the specializeddeep_replace_property
(used forsimplified
andoptimized_for_numpy
) andshallow_replace
(used forreplace_arguments
,_deep_flatten_constants
and_combine_loop_concatenates
). The differences between the two constructs are as follows:@deep_replace_property
@shallow_replace