-
Notifications
You must be signed in to change notification settings - Fork 59
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 import #1948
Comments
I ran the same tests and piped it through tuna, like I did in #1135 and here's a snapshot: I fear that most time is not lost by loading indicators. |
Regarding the load time of indices, what I did is I commented |
This would certainly help in #1955 , since the main slow-down for command-line tools is the import time for xclim (followed by the start-up time for python). Would it be possible to have the register for indices (needed for the CLI) be created during |
We could export a json of the indicators and parameters, on install. That would break the idea that "virtual submodule" are loaded live, but maybe that's ok for the CLI. However, as long as we don't change how the indicators modules are structured, I don't think that would improve anything else than Another issue of ahead-of-time compilation is that we need to specify all possible signatures in advance, no? Not impossible, but seems sub-optimal. |
I think the command is Indeed, and with the deprecation for |
Addressing a Problem?
Import takes 2.5s on my laptop.
Benchmark using
python -X importtime test.py
where test.py is just
import xclim
Potential Solution
xclim.indicators
: 0.1 sxclim.indices
: 0.7 sFor reference, here are import times for some of our dependencies. Note that these numbers are only valid in the xclim context, you'd get different results by testing them individually, since they import each other.
Additional context
Code for lazy import (https://docs.python.org/3/library/importlib.html#implementing-lazy-imports)
Note that if we lazy import indicators, then they're not in the xclim registry. So the virtual module creation, which relies on the registry, would need to trigger their import.
Contribution
Code of Conduct
The text was updated successfully, but these errors were encountered: