diff --git a/.github/benchmarks/lazy-imports-after.png b/.github/benchmarks/lazy-imports-after.png new file mode 100644 index 0000000..f6e902f Binary files /dev/null and b/.github/benchmarks/lazy-imports-after.png differ diff --git a/.github/benchmarks/lazy-imports-before.png b/.github/benchmarks/lazy-imports-before.png new file mode 100644 index 0000000..2a647d7 Binary files /dev/null and b/.github/benchmarks/lazy-imports-before.png differ diff --git a/changelog.d/+lazy-pathlib.performance.md b/changelog.d/+lazy-pathlib.performance.md new file mode 100644 index 0000000..527b87c --- /dev/null +++ b/changelog.d/+lazy-pathlib.performance.md @@ -0,0 +1 @@ +Reduce Python startup time and memory use when pre-commit-uv is installed on Python 3.15. diff --git a/src/pre_commit_uv/_pre_commit_patch.py b/src/pre_commit_uv/_pre_commit_patch.py index 8798b5f..b4d4502 100644 --- a/src/pre_commit_uv/_pre_commit_patch.py +++ b/src/pre_commit_uv/_pre_commit_patch.py @@ -2,6 +2,10 @@ from __future__ import annotations +__lazy_modules__ = [ + "pathlib", +] + # only import built-ins at top level to avoid interpreter startup overhead import os import pathlib