'New conda environment is slow to import on MacOS

I've noticed that on my Mac (but not Linux machine) when I have a new conda environment and then import a library like numpy in it, it takes a fairly long time to do it. The second time is nearly instant though.

That is, if I run the following:

export NAME=tmp_conda_env
conda deactivate
conda env remove -n $NAME -y
conda create -y -n $NAME python=3.10.0 numpy=1.21.2
conda activate $NAME
time (echo "import numpy" | python)
time (echo "import numpy" | python)

I get:

real    0m9.396s
user    0m0.191s
sys 0m0.079s

real    0m0.278s
user    0m0.192s
sys 0m0.061s

In general the first import of numpy takes considerably longer (at least wall-clock) time. Does anyone know why that is?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source