-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Prevent quadratic runtime for overlap check at large overload counts #15865
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternate fix would be to only check the first 100 overloads for overlaps.
I think I'd weakly prefer that? Performance is obviously still very important for us, but it's not as important as it is for pyright, since pyright doubles as a language server. And it feels weird that you might get 50 overlapping-overload errors if you had 99 overloads, but then that number drops to 0 when you added one more overload.
|
Yeah, I don't like silently skipping all checks if there are many overloads. I think we should just limit inner loop to say 100 next items, this way we will check all "nearby" overloads with linear complexity. Also if we hit this limit, we should show an error on the first line saying that some checks were skipped (as we do e.g. for union math). User may then place a single Also we can still always do the implementation completeness check that is linear (and it doesn't affect stubs anyway). |
|
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
+ discord/client.py:1233: error: Not all overload combinations were checked for overlap because there were too many [misc]
scipy-stubs (https://github.com/scipy/scipy-stubs)
+ scipy-stubs/sparse/_construct.pyi:118: error: Not all overload combinations were checked for overlap because there were too many [misc]
+ scipy-stubs/sparse/_construct.pyi:1362: error: Not all overload combinations were checked for overlap because there were too many [misc]
+ scipy-stubs/sparse/_construct.pyi:1493: error: Not all overload combinations were checked for overlap because there were too many [misc]
+ scipy-stubs/sparse/_construct.pyi:1623: error: Not all overload combinations were checked for overlap because there were too many [misc]
+ scipy-stubs/sparse/_construct.pyi:1771: error: Not all overload combinations were checked for overlap because there were too many [misc]
|
Fixes #10004
An alternate fix would be to only check the first 100 overloads for overlaps.