Skip to content

perf: defer Python installer import - #3836

Merged
frostming merged 1 commit into
pdm-project:mainfrom
yangfan-yf-yf:perf-3673-lazy-pbs-installer
Aug 9, 2026
Merged

perf: defer Python installer import#3836
frostming merged 1 commit into
pdm-project:mainfrom
yangfan-yf-yf:perf-3673-lazy-pbs-installer

Conversation

@yangfan-yf-yf

Copy link
Copy Markdown
Contributor

Fixes #3673.

Summary

  • move the PythonVersion import behind TYPE_CHECKING, so command registration does not load pbs_installer
  • extend the clean-subprocess startup regression to cover the Python installer package
  • update the existing Improve the startup performance #3673 news fragment

Why

pdm.project.core only uses PythonVersion in deferred annotations. Importing it at module load time also imports the Python installer stack for commands that never install a Python interpreter.

Validation

  • the startup regression failed before the change with pbs_installer loaded and passes after the change
  • targeted startup and minimum/maximum matching tests: 3 passed
  • tests/cli/test_venv.py and tests/test_project.py: 104 passed, 3 skipped
  • non-integration suite: 1279 passed, 25 skipped, 1 xfailed; the remaining 4 Windows environment failures were reproduced on unchanged main (symlink privilege and unavailable POSIX cat/echo commands)
  • Ruff check and format check passed for the changed Python files
  • Codespell and git diff --check passed
  • Mypy passed for src/pdm/project/core.py; the full locally resolved run had the same 38 dependency-version errors on this branch and unchanged main

@yangfan-yf-yf
yangfan-yf-yf marked this pull request as ready for review August 9, 2026 13:43
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.16%. Comparing base (b3cb02e) to head (d9a9a04).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3836      +/-   ##
==========================================
- Coverage   88.16%   88.16%   -0.01%     
==========================================
  Files         121      121              
  Lines       13221    13220       -1     
  Branches     2246     2246              
==========================================
- Hits        11656    11655       -1     
  Misses        982      982              
  Partials      583      583              
Flag Coverage Δ
unittests 88.04% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frostming
frostming merged commit d98f6bb into pdm-project:main Aug 9, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the startup performance

2 participants