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

Speed up State.finish_passes #18302

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Speed up State.finish_passes #18302

merged 1 commit into from
Dec 18, 2024

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Dec 17, 2024

Don't use a set to deduplicate mypy Type objects, since taking the hash of a type, and possibly comparing for equality (which is needed to add a type to a set) is more expensive than processing duplicates in TypeIndirectionVisitor. Many of the most expensive types to process are complex types such as callables, which often don't have many duplicates and have complex __hash__ methods.

This seems to speed up type checking torch slightly, by about 0.5% (average of 100 runs).

Don't use a set to deduplicate types, since taking the hash of a type
(which is needed to add a type to a set) is more expensive than
processing a type in TypeIndirectionVisitor.
Copy link
Contributor

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

@JukkaL JukkaL merged commit 7d81f29 into master Dec 18, 2024
19 checks passed
@JukkaL JukkaL deleted the faster-state branch December 18, 2024 16:43
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