Skip to content

gh-153568: Skip parser memo lookups that cannot match#153571

Open
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-153568-memo-filter
Open

gh-153568: Skip parser memo lookups that cannot match#153571
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-153568-memo-filter

Conversation

@pablogsal

@pablogsal pablogsal commented Jul 11, 2026

Copy link
Copy Markdown
Member

Most memoization probes miss, and each one walked a linked list through arena memory to find out. A per-token filter of the memoized rule types answers definite misses with a single bit test.

Benchmark (parsing 8 of the largest stdlib files, 1.3 MB, 20 times per run with _PyParser_ASTFromString — parser only, no AST-to-Python conversion; pyperf, interleaved runs):

build time per run speedup
main 1.82 s
this PR 1.72 s 1.06x faster

Each token now carries a small filter of the rule types present in its
memo list, so the common case of a miss no longer walks the list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant