Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize type indirection visitor #18298

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Optimize type indirection visitor #18298

merged 2 commits into from
Dec 17, 2024

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Dec 16, 2024

This was a performance bottleneck when type checking torch. It used to perform lots of set unions and hash value calculations on mypy type objects, which are both pretty expensive. Now we mostly rely on set contains and set add operations with strings, which are much faster. We also avoid constructing many temporary objects.

Speeds up type checking torch by about 3%. Also appears to speed up self check by about 2%.

This was a performance bottleneck when type checking torch. It used
to perform lots of set unions and hash value calculations on
mypy type objects, which are both pretty expensive. Now we mostly
rely on set contains and set add operations with strings, which are
much faster. We also avoid constructing many temporary objects.

Speeds up type checking torch by about 3%. Also appears to speed up
self check by about 2%.

This comment has been minimized.

Copy link
Contributor

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

@hauntsaninja hauntsaninja merged commit 73ba1e7 into master Dec 17, 2024
19 checks passed
@hauntsaninja hauntsaninja deleted the faster-indirection branch December 17, 2024 10:18
@hauntsaninja
Copy link
Collaborator

Nice!

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.

None yet

2 participants