Installation speed of multiple python packages using pip
What’s faster - multiple pip install
statements, or one with a list of wanted libraries? Lets do a quick check:
➜ test cat 1.sh
pip install "pytest>=7.0,<7.1"
pip install "pytest-mock>=3.7,<3.8"
pip install "pytest-subtests>=0.6,<0.7"
pip install "pytest-cov>=3.0,<3.1"
➜ test cat 2.sh
pip install "pytest>=7.0,<7.1" "pytest-mock>=3.7,<3.8" "pytest-subtests>=0.6,<0.7" "pytest-cov>=3.0,<3.1"
Results:
./1.sh 4.91s user 0.53s system 72% cpu 7.500 total
./1.sh 4.98s user 0.37s system 75% cpu 7.076 total
./1.sh 5.06s user 0.49s system 76% cpu 7.278 total
./2.sh 2.56s user 0.24s system 71% cpu 3.903 total
./2.sh 3.36s user 0.23s system 79% cpu 4.519 total
./2.sh 2.64s user 0.27s system 75% cpu 3.872 total
Results were generated by hand as following:
➜ test rm -rf venv ; python3 -m venv venv ; source venv/bin/activate ; pip install -U pip
Collecting pip
[...]
Successfully installed pip-22.0.3
(venv) ➜ test time ./2.sh ; deactivate
Collecting pytest<7.1,>=7.0
[...]
Successfully installed [...]
./2.sh 2.64s user 0.27s system 75% cpu 3.872 total