FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Micro-optimize type indirection visitor by JukkaL · Pull Request #19460 · python/mypy · GitHub

Repository navigation

Micro-optimize type indirection visitor - #19460

Merged
JukkaL merged 1 commit into
masterfrom
opt-2
Jul 18, 2025
Merged

JukkaL merged 1 commit into
masterfrom
opt-2

Conversation

JukkaL commented Jul 16, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator

Specialize iteration for the concrete types list and tuple, since this is faster than iterating over an abstract iterable in compiled code. Also avoid constructing many temporary lists.

Duplicate some very hot code in the hopes further improving performance slightly, through inlining and possibly also better branch prediction.

The approach is similar to what I used in #19459.

This is a part of a set of micro-optimizations that improve self check performance by ~5.5%.

Specialize iteration for the concrete types `list` and `tuple`,
since this is faster than iterating over an abstract iterable
in compiled code.

Duplicate some very hot code in the hopes further improving
preformance slightly, through inlining and possibly also better
branch prediction.

This is a part of a set of micro-optimizations that improve self check
performance by ~5.5%.
JukkaL requested a review from ilevkivskyi July 16, 2025 12:57

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Interesting, I would never guess this is a hot code path.

JukkaL merged commit 23e6072 into master Jul 18, 2025
JukkaL deleted the opt-2 branch July 18, 2025 08:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL