-
Notifications
You must be signed in to change notification settings - Fork 168
feat: optimize apply_formatter_at_index #306
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
base: main
Are you sure you want to change the base?
Conversation
formatter: Callable[..., Any], at_index: int, value: List[Any] | ||
) -> Generator[List[Any], None, None]: | ||
if at_index + 1 > len(value): | ||
try: |
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.
we can do this check optimistically since we expect it to succeed most often
eth_utils/applicators.py
Outdated
|
||
yield from value[:at_index] | ||
yield formatter(item) | ||
if remaining := value[at_index+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.
only one if check to do, everything else just flows out the way it came in
) from None | ||
|
||
yield from value[:at_index] | ||
yield formatter(item) |
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.
And then we don't need to perform any additional checks
What was wrong?
Related to Issue #
Closes #
How was it fixed?
Todo:
Cute Animal Picture