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
Importing scikit-rf imports many modules and is slow #1057
Comments
It seems we are not the only ones discussing the issue of lazy loading modules while maintaining the ergonomics of e.g. |
Here's a breakdown of where the import times are coming from. (This is the command used to get this):
where the contents of
A better way to view might be a flamegraph like this one: Will let you know what more I can find |
Ok so going through some stuff, I definitely think lazy loading is called for. Especially for things that aren't required for all operations. I often don't need to plot, so I shouldn't be loading matplotlib, even if it's available, at least until I use it. Especially considering roughly 1/3rd of the startup time is due to just mpl. I was able to shave off 300ms just by moving the pandas imports in the io module to the respective functions that need them. |
+1 for lazy loading, because I was the one who brought the issue up. |
I'll try to take a crack at it today! |
Issue created following this post on reddit.
The number of modules imported in the namespace when importing scikit-rf is quite large and can take quite some times.
Just importing
skrf.constants
imports PIL, scipy, matplotlib, pandas, and all of the skrf modules, and generally takes about 1 second to complete (where numpy takes around 150 ms).Here's an example showing the difference between numpy import and skrf imports. First, here's numpy as a baseline.
numpy
numpy import: 0.13497460004873574
List of imported modules.
scikit-rf
With the result:
SKRF import: 1.014745100052096
List of imported modules
The text was updated successfully, but these errors were encountered: