-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Generic classes cause massive slowdown or hang #11484
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
Comments
I actually cannot run this on my machine, left it running for ~2 hours with no result. |
Is there a standalone Python file that is slow to type check? I also see you have multiple mypy plugins. Does disabling them help? |
@hauntsaninja I think the worst offender is the code generated from https://github.com/RobertCraigie/prisma-client-py/blob/main/src/prisma/generator/templates/types.py.jinja On mobile right now but will share an example of the generated file when possible and check if disabling the plugins helps. The auto-generated file is basically a lot of nested and pseudo-recursive TypedDicts, I think the last time I checked the size of the mypy cache for this file was around 400MB, that could be the issue? |
stand alone |
Mypy was slightly faster without the plugins, but still taking nearly 28 minutes |
The stand alone |
I'm in a very similar situation, and can confirm that generics and nested dicts/type aliases do not mesh well currently. I recently started to add a bunch of genericity to refactor some of our code. I've tried running mypy for more than 15 minutes, and mypy still hadn't returned its errors; so I was thinking this was possibly an issue on my end - until I came across this thread. Clearly it's taking an ungodly long time, compared to the usual minute or so that it takes to check our "non-generic" codebase. |
Did you ever manage to make a standalone repro? We've made a series of recent performance fixes. |
I did not manage to create a standalone repository but I have been able to add the generic types back in and running mypy with v1.4.1 is much faster. It now seems to be between 15-20s locally which is insane, thank you! |
Uh oh!
There was an error while loading. Please reload this page.
Hi, this commit, causes mypy to go from ~7 minutes to ~30 minutes to typecheck the whole codebase.
It should be noted that the code in the mentioned commit is used to auto-generate 5 classes, each with 9 methods that use the generic typevar. These methods don't do anything special but the arguments are heavily nested TypedDicts. The classes look like this:
If it is still relevant, this #3796 (comment) might explain some of the reasons behind this performance loss.
I'm sorry I don't have a smaller example, I don't have enough time to dig any deeper into this issue.
The text was updated successfully, but these errors were encountered: