Prevent quadratic runtime for overlap check at large overload counts#15865
Prevent quadratic runtime for overlap check at large overload counts#15865hauntsaninja wants to merge 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.