Speed up State.finish_passes by JukkaL · Pull Request #18302 · python/mypy (original) (raw)
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).