Open SteffenMeinecke opened 1 year ago
We should also discuss to maybe introduce a more modular approach. At the moment, if you import pandapower nearly everything gets loaded directly (since many init.py's). I would like to see an approach, where you need to import pandapower.timeseries and only then the timeseries imports are loaded.
I would like to see an approach, where you need to import pandapower.timeseries and only then the timeseries imports are loaded.
I guess to decrease the import time? If one import pandapower once at the beginning of a calculation run, it should be no big deal right now, or am I wrong?
I guess to increase the import time? If one import pandapower once at the beginning of a calculation run, it should be no big deal right now, or am I wrong?
Yes, to increase import time. Importing only the functions used should be alot faster than importing all functions.
The issue is that this will currently not improve load time because alot of functions within pandapower actually import the whole package.
So even when importing only one function it will most likely load all modules. This can be inspected with python -X importtime -c "<command>"
.
Example:
python -X importtime -c "from pandapower.plotting.geo import dump_to_geojson"
This will show all loadtimes for each loaded package and function. It also shows that using the import as mentioned will actually not help prevent loading all modules. (Maybe if they are removed from init.py, have not tested that) Currently it shows that the loading process for pandapower as a whole took 4137356μs (4.13s).
I would consider importing for 4.13s before even starting a calculation a big deal, but that is up to interpretation.
The longest none pandapower modules imported were pandas, scipy.stats, scipy.interpolate. pandas took .56s to load, which is significantly faster than 4.13s. scipy should not be required for the dump_to_geojson function. scipy.stats loaded in .37s and scipy.interpolate loaded in .35s. Avoiding loading of all not required modules is a good idea to get the overall load time down, as all loding times are cumulative. So the time for pandapower includes all of its dependencies, as they need to be loaded before pandapower can be loaded.
Feature Checklist
1. How to import Recommended ways of importing basic pandapower functionaliy, e.g.
runpp()
should look like (as it is)Recommended ways of importing futher pandapower functionaliy, e.g.
from_ppc()
should look likeNot recommended for usage outside the pandapower package itself (for functions not starting with
_
):Reason: pandapower might move or rename the file containing from_ppc
Remark:
pp.converter
should be first available with https://github.com/e2nIEE/pandapower/pull/1916TODOs:
2. Remove direct availability of toolbox functions and some others with
import pandapower
(pp.toolbox.fct() # is recommended
)Will destroy users' code that uses functions in question from
import pandapower
-> we should be clear that we really want that -> if yes, deprecation warnings are needed, seeTODOs in case we want that: 1st:
import pandapower
anymore (toolbox, some of auxiliary, ...)2nd: