Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yabirgb
Copy link

@yabirgb yabirgb commented Aug 16, 2025

What was wrong?

Parts of the code had redundant code

How was it fixed?

simplified the code while keeping the same checks. For the to_checksum_address function I tried to see if it was possible to improve its performance but I didn't manage to get anything meaninful

➜  eth-utils git:(main) ✗ hyperfine --warmup 3 --runs 10 'uv run --no-project reg.py'
Benchmark 1: uv run --no-project reg.py
  Time (mean ± σ):     234.1 ms ±   1.2 ms    [User: 214.9 ms, System: 17.9 ms]
  Range (min … max):   232.8 ms … 236.4 ms    10 runs

➜  eth-utils git:(main) ✗ git checkout improvements
Switched to branch 'improvements'
➜  eth-utils git:(improvements) ✗ hyperfine --warmup 3 --runs 10 'uv run --no-project reg.py'
Benchmark 1: uv run --no-project reg.py
  Time (mean ± σ):     232.0 ms ±   0.9 ms    [User: 213.0 ms, System: 17.9 ms]
  Range (min … max):   230.8 ms … 233.6 ms    10 runs

This is reading and checksumming 10k addresses

Todo:

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

Cute Animal Picture

4BCDDAE9-6F52-4A2F-9420-4F7D4BC22ABE_1_105_c

Comment on lines +133 to +134
# is_hex_address already checks if it is_text
return is_hex_address(value) and bool(value == to_checksum_address(value))
Copy link
Author

Choose a reason for hiding this comment

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

here it removes a redundant function call

Comment on lines -121 to +110
else:
return bool(to_normalized_address(left) == to_normalized_address(right))

return to_normalized_address(left) == to_normalized_address(right)
Copy link
Author

Choose a reason for hiding this comment

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

the cast is not needed here. Only when the argument has type Any

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