Skip to content

feat: optimize with iterators #3652

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

BobTheBuidler
Copy link

@BobTheBuidler BobTheBuidler commented Mar 25, 2025

What was wrong?

The formatters init quite a few lists each run, and can be made much more efficient using iterators. This PR does so.

I figured this was more important than the logger stuff in my last PR so finished this one up first.

Related to Issue # N/A
Closes # N/A

How was it fixed?

creation of an IteratorProxy class that allows map objects to be passed thru the formatters instead of fully materializing a list every step of the way

Todo:

  • Clean up commit history
  • Add or update documentation related to these changes
  • Add entry to the release notes

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->


@curry
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> List[Any]:
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> "map[ABITypedData]":
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea for more optimization: rip out this func and replace it with a lambda which would have less overhead than using curry

[abi_data_tree(types)],
map(data_tree_map, normalizers),
[partial(recursive_map, strip_abi_type)],
return pipe(
Copy link
Author

@BobTheBuidler BobTheBuidler Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be further optimized by caching the pipe per-method as a compose object

@BobTheBuidler BobTheBuidler marked this pull request as ready for review April 5, 2025 17:07
@BobTheBuidler BobTheBuidler force-pushed the patch-3 branch 7 times, most recently from ee5190b to 11a0672 Compare April 17, 2025 22:07
BobTheBuidler and others added 12 commits April 18, 2025 20:31
This was originally part of my other PR but that is becoming quite cluttered and hard to review so I separated this one out. 

Previously, the code would create a new dict from `d` one time for each item in the iterable.

Now, the code creates just one new dict from `d` at the beginning and uses that same dict to check membership for each item.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant