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

Mypy micro-optimizations (batch 1/3) by JukkaL · Pull Request #19768 · python/mypy · GitHub

Repository navigation

Mypy micro-optimizations (batch 1/3) - #19768

Merged
hauntsaninja merged 4 commits into
masterfrom
mypy-opts-1
Aug 31, 2025
Merged

hauntsaninja merged 4 commits into
masterfrom
mypy-opts-1

Conversation

JukkaL commented Aug 31, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator

Several mypy micro-optimizations. Together with batches 2 and 3 these improve self check performance by 1.8%.

Copy link
Copy Markdown
Contributor

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

hauntsaninja merged commit 87f4dc8 into master Aug 31, 2025
hauntsaninja deleted the mypy-opts-1 branch August 31, 2025 22:36
Comment thread mypy/types.py
Comment on lines -2126 to +2128
self.variables = variables
self.variables: tuple[TypeVarLikeType, ...]
if variables is None:
self.variables = ()
else:
self.variables = tuple(variables)

cdce8p Sep 1, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator

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

Note, this does crash the pydantic.v1 extension.

  File "/.../python3.13/site-packages/pydantic/v1/mypy.py", line 868, in add_method
    signature.variables = [tvar_def]
    ^^^^^^^^^^^^^^^^^^^
TypeError: tuple object expected; got list

https://github.com/pydantic/pydantic/blob/v2.11.7/pydantic/v1/mypy.py#L866-L868

It can fairly easily be fixed and I'll open a PR for it soon. However, that might not be the only plugin which depends on it being "just" a sequence.

Copy link
Copy Markdown
Collaborator Author

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

If we have evidence that this impacts multiple plugins, we can consider reverting this change.

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.

3 participants


Back | FazBrowse Home | New Git URL