From c60f3a22eccdd1fafa9a1d5a52596fc259ef62a1 Mon Sep 17 00:00:00 2001 From: Richard Si Date: Wed, 29 Jan 2025 15:24:06 -0500 Subject: [PATCH] perf: pass --no-compile for build deps 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. --- news/7294.feature.rst | 2 ++ src/pip/_internal/build_env.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 news/7294.feature.rst diff --git a/news/7294.feature.rst b/news/7294.feature.rst new file mode 100644 index 00000000000..ee459870210 --- /dev/null +++ b/news/7294.feature.rst @@ -0,0 +1,2 @@ +Build environment dependencies are no longer compiled to bytecode during +installation for a minor performance improvement. diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py index e820dc3d5fb..746cd0950a8 100644 --- a/src/pip/_internal/build_env.py +++ b/src/pip/_internal/build_env.py @@ -242,6 +242,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",