feat: optimize passing data thru formatters #3699
Open
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.
What was wrong?
In the current code, data_tree_map is called multiple times in rapid succession. This occurs for every call that is formatted.
data_tree_map creates and populates a new list each time its called, which is quite wasteful and not necessary for our use case, especially when we're calling it recursively
This PR changes the codebase so, instead of creating and populating a new list object at each and every stage of formatting, now we pass
map
objects thru the formatters and only create and populate one list when the formatting is complete.The only api that changed was in an internal module, and the codebase was adapted accordingly. This small change makes a much bigger difference than the past few PRs did, so I'm hoping this API change doesn't block us from merging.
@kclowes you can use the same benchmark script you used for the last PR, you will see a tangible difference on that benchmark and you should also in the overall testing times
Related to Issue #
Closes #
How was it fixed?
Todo:
Cute Animal Picture