Skip to content

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

3 participants