17 ms·
On the general topic of Python performance, just importing needed modules can take a few seconds. The output of the code import time start = time.time()
by Bostonian 2y ago
On the general topic of Python performance, just importing needed modules can take a few seconds. The output of the code
import time
start = time.time()
import os
import numpy as np
import pandas as pd
import xgboost as xgb
from sklearn.metrics import mean_squared_error
from scipy.stats import pearsonr
import matplotlib.pyplot as plt
print("time elapsed (s):", "%0.3f"%(time.time() - start))
on my Windows machine is
time elapsed (s): 2.630
- nitely 2y agoIf those libraries are doing something at import time, then it could take any amount of time, TBF.
- noitpmeder 2y agoNot sure why this matters too too much, this is a one-time setup cost (of some significantly large libraries). Python doesn't import everything in your virtual environment at startup, which I think we can agree is the right choice. I'd further _guess_ that only one or two of those libraries are the actual slowdowns. See here for how to tell: https://stackoverflow.com/a/51300944/602469 https://stackoverflow.com/a/51300944/602469
- cryptonector 2y agoIt matters when you have lots of short-lived processes.
- incorrecthorse 2y agoIt can take an arbitrary amount of time. Modules are just code executed top to bottom, and might contain anything beyond mere constants and functions declaration.