-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: optimize apply_abi_formatters_to_dict #3671
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
| formatted_dict = dict(zip(fields, formatted_values)) | ||
| return dict(data, **formatted_dict) | ||
| formatted_dict = data.copy() | ||
| formatted_dict.update(zip(fields, formatted_values)) |
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.
Instead of fully initializing a formatted_dict and then initializing a second new dict with it, we can just init one copy of the original dict and update it from a zip
56c895d to
b189b01
Compare
| [abi_dict[field] for field in fields], | ||
| [data[field] for field in fields], | ||
| (abi_dict[field] for field in fields), | ||
| (data[field] for field in fields), |
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.
2 less list creations per call
pacrob
left a comment
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 good, thanks @BobTheBuidler!
What was wrong?
nothing was wrong, but apply_abi_formatters_to_dict is used frequently so was suitable for optimization
Related to Issue #N/A
Closes #N/A
Todo:
Cute Animal Picture