Some python modules, notably matplotlib
, take a long time to load
start = datetime.datetime.now(); import numpy, pandas, matplotlib, sklearn; datetime.datetime.now() - start
takes half a second with cached files, and several seconds for non-cached files. Is there a way to load these modules in the background, when in the Python interpreter?
You can import modules in separate threads. Here is the solution.
Create a file
load_modules.py
:Then you can start interpreter with a command:
Or just run
in your interpreter to load modules.