For example, the same code in anaconda environment is running noticeably slower than in bare python env
import multiprocessing as mp
from tqdm.auto import tqdm
def summer(i):
return i+i
with mp.Pool(6) as pool:
data = range(100000)
results = tqdm(pool.imap_unordered(summer, data), total=len(data))
results = list(results)
pool.close()
pool.join()
time in python env:
$time python testscript.py
100%|████████████████████████████| 100000/100000 [00:02<00:00, 45094.94it/s]
real 0m2,316s
user 0m3,953s
sys 0m1,525s
time in conda env:
$time python testscript.py
100%|████████████████████████████| 100000/100000 [00:03<00:00, 26315.68it/s]
real 0m3,873s
user 0m6,157s
sys 0m1,912s
What could be the underlying reason of it? Tried profiling the code with viztracer, but it simply shows that summer() takes longer to execute. Follow-up question: Is there a way to profile deeper in python?