Skip to content

perf: short-circuit identical address comparison - #331

Open
BobTheBuidler wants to merge 1 commit into
ethereum:mainfrom
BobTheBuidler:perf/short-circuit-identical-addresses
Open

perf: short-circuit identical address comparison#331
BobTheBuidler wants to merge 1 commit into
ethereum:mainfrom
BobTheBuidler:perf/short-circuit-identical-addresses

Conversation

@BobTheBuidler

Copy link
Copy Markdown
Contributor

What I did

Added a fast path for exact address matches in is_same_address().

fixes: N/A

How I did it

The function still validates both inputs first. If the validated inputs are exactly equal, it returns True before normalizing both addresses for comparison.

How to verify it

Run python -m pytest tests/core/address-utils/test_address_utils.py, tox -e py310-core, and tox -e py310-lint.

Local microbench for is_same_address(addr, addr): 4.11 usec per loop on upstream base, 578 nsec per loop on this branch, about 7.1x faster for the exact-match path.

Checklist

  • All changes are completed
  • Change is covered in tests
  • Documentation is complete

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.

2 participants