Skip to content

Commit

Permalink
perf: pass --no-compile for build deps (pypa#13192)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ichard26 authored Feb 9, 2025
1 parent 6154c38 commit 3994c61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions news/7294.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Build environment dependencies are no longer compiled to bytecode during
installation for a minor performance improvement.
4 changes: 4 additions & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def _install_requirements(
prefix.path,
"--no-warn-script-location",
"--disable-pip-version-check",
# 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.
"--no-compile",
# The prefix specified two lines above, thus
# target from config file or env var should be ignored
"--target",
Expand Down

0 comments on commit 3994c61

Please sign in to comment.