Skip to content

Conversation

ilevkivskyi
Copy link
Member

This uses dedicated secondary type tags to 5 most common instances. I also move the instance cache from checker.py to types.py so it is easier to share. The latter however requires couple tweaks to not break builtins fixtures in tests (see changes in build.py and checkexpr.py).

This makes cache another ~20% smaller (so that with this PR FF is 4.5x smaller than JSON), and also this makes mypy -c 'import torch' almost 10% faster with warm cache (when one uses --fixed-format-cache obviously). I don't see any visible effect on cold cache runs.

Copy link
Contributor

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

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks, excellent wins! It makes sense optimize for the common case, especially when the common case is very common.

@ilevkivskyi ilevkivskyi merged commit b8ee1f5 into python:master Sep 1, 2025
20 checks passed
@ilevkivskyi ilevkivskyi deleted the compact-instance branch September 1, 2025 17:11
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