Skip to content

Commit 3994c61

Browse files
authored
perf: pass --no-compile for build deps (#13192)
As the build environment is ephemeral, it's wasteful to pre-compile everything, especially as not every Python module will be used/compiled in most cases. In addition, the argument is that compilation ensures read-only installations are not slower than necessary is moot as the build environment is by design writable. This saves ~200ms while installing setuptools while building pip itself. For context, a pip install . (with --no-index and --find-links) takes 3400ms on main and pip wheel . takes 2200ms on main. So, it's not a major win, but it's also nothing to sneeze at. Packages using smaller backends, like flit, will likely see smaller improvements.
1 parent 6154c38 commit 3994c61

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

news/7294.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Build environment dependencies are no longer compiled to bytecode during
2+
installation for a minor performance improvement.

src/pip/_internal/build_env.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ def _install_requirements(
240240
prefix.path,
241241
"--no-warn-script-location",
242242
"--disable-pip-version-check",
243+
# As the build environment is ephemeral, it's wasteful to
244+
# pre-compile everything, especially as not every Python
245+
# module will be used/compiled in most cases.
246+
"--no-compile",
243247
# The prefix specified two lines above, thus
244248
# target from config file or env var should be ignored
245249
"--target",

0 commit comments

Comments
 (0)