KEMBAR78
Optimize type indirection visitor by JukkaL · Pull Request #18298 · python/mypy · GitHub
Skip to content

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%.
@github-actions

This comment has been minimized.

@github-actions
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.

2 participants