Skip to content

perf: precompile tuple ABI type regex - #330

Open
BobTheBuidler wants to merge 1 commit into
ethereum:mainfrom
BobTheBuidler:perf/precompile-tuple-abi-regex
Open

perf: precompile tuple ABI type regex#330
BobTheBuidler wants to merge 1 commit into
ethereum:mainfrom
BobTheBuidler:perf/precompile-tuple-abi-regex

Conversation

@BobTheBuidler

Copy link
Copy Markdown
Contributor

What I did

Precompiled the tuple ABI type regex used by ABI tuple alignment.

fixes: N/A

How I did it

The regex is compiled once at module import time and reused by _get_tuple_type_str_and_dims(). The parsing behavior is covered with tuple-array cases, including fixed-size tuple arrays.

How to verify it

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

Local microbench for _get_tuple_type_str_and_dims("tuple[]"): 371 nsec per loop on upstream base, 211 nsec per loop on this branch, about 43% faster. A public get_aligned_abi_inputs() tuple-array call measured 4.48 usec per loop on upstream base and 3.71 usec per loop on this branch, about 17% faster.

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