-
Notifications
You must be signed in to change notification settings - Fork 114
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
Using typecheck decorator slows module import dramatically #468
Comments
I also have performance issues when importing code using |
It slows down the first import of a module. Subsequent imports should be fine when loaded from bytecode cache. Let me know if this is not the case. |
Oh, sorry, indeed with |
@agronholm this is the case, however this is an issue nontheless I encountered this issue while using Edit: was written after your first comment Edit 2: ok now I understand what you mean by first, |
@agronholm Hi! I reached out to you via e-mail. Let me know if you're interested in me taking the full responsibility of resolving this. |
Things to check first
Feature description
As a result of researching why the import of the
inflect
library was slow I found out that the@typechecked
decorator was the main reason.See jaraco/inflect#212
I believe that the same solution suggested in this issue can also be applied generally, the solution being to defer running the typechecked decorator until the decorated function is actually called, and to cache the result of the "decoration" as otherwise every call to the decorated function will be slow
Something like this:
Use case
Faster imports for all direct and indirect users of typeguard
The text was updated successfully, but these errors were encountered: