Like many users, python import is most of the time extremely slow at importing modules. For instance, a simple :
time echo "import pandas" | python3.12
usually take about 4s to 6s on my Intel MacBook pro 16″, except when the laptop is cold enough. In this case it takes an acceptable 0.6s. Since I’m most of the time working with an external display that activates the second GPU, the laptop is always hot enough to slow down python import.
After many experiments, I discovered that import speed is not directly correlated to the hardware temperature but to the speed of the right fan! Indeed, starting from a state where python import is fast (0.6s), speeding up the right fan manually (using Macs Fan Control) slows down python import up to 5s for the maximal fan speed.
More findings:
- I can even observe a slowdown proportional to the fan speed.
- The left fan speed has no effect.
- I cannot find any other application or benchmark (I tested CPU, RAM and SSD benchmarks) that exhibits such a correlation (with the fan speed or with the HW temperature).
- This can be observed on other Intel macbook pro
- This can be observed with any python distribution and version (brew, conda, macports, …)
I’m looking forward for any suggestions to solve this weird issues or to dig further.
