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 finding function type variables #16562

Merged
merged 2 commits into from
Dec 28, 2023
Merged

Speed up finding function type variables #16562

merged 2 commits into from
Dec 28, 2023

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Nov 25, 2023

Merge two visitors into a single visitor that is a bit more optimized than the old visitors.

This speeds ups tests, in particular -- mypy/test/testcheck.py is about 4% faster and mypy/test/testpythoneval.py is about 3% faster.

Also self-check is about 1% faster, both interpreted and compiled.

This adds more code, but the new code is largely boilerplate, so the difficulty of maintenance seems roughly the same.

This used to be a significant performance bottleneck, especially in
tests.

Merge logic from two type visitors into a single visitor. Also don't
rely on generic type query visitors but implement logic for all types
directle, since it will be faster.
Copy link
Contributor

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

@JukkaL
Copy link
Collaborator Author

JukkaL commented Dec 28, 2023

Going to merge this now, to avoid this getting stale. If anybody wants to review this afterwards, I'm happy to address feedback in a follow-up PR.

@JukkaL JukkaL merged commit 761965d into master Dec 28, 2023
18 checks passed
@JukkaL JukkaL deleted the faster-tests-typevar branch December 28, 2023 11:27
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.

1 participant