Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9105854f3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cached = self._class_public_member_reference_cache.get(cache_key) | ||
| if cached is not None: | ||
| return cached |
There was a problem hiding this comment.
Invalidate class member count cache during class traversal
_public_member_reference_count is called multiple times while the same class AST is being mutated, but this cache never refreshes once populated. In keep_global_variables=True flows, earlier methods can rewrite receiver names (for example self → a when rename_arguments=True), so later rename decisions should use the updated tree; reusing the old counts overestimates member usage and can trigger renames that increase output size (e.g. LongClassName.foo/bar gets bar renamed with an alias, producing longer minified code than before this commit).
Useful? React with 👍 / 👎.
Summary
_public_member_reference_count, which was the dominant hotspot in package modeMeasured Impact
One-shot package minification on the checked-in fixtures with
keep_module_names=False,keep_global_variables=False, andrename_arguments=True:click:9.290sonorigin/main->3.529son this branchpytest:27.858sonorigin/main->15.592son this branchA profiler run on the
pytestfixture showed_public_member_reference_countand its repeatedast.walkcalls dominating runtime onmain; after caching, that hotspot drops out of the top line items and total runtime falls materially.Validation
.venv/bin/python -m pytest -q.bench-repos/click/srcand.bench-repos/pytest/src