Profiling startup import time of Python programs
How to speed up Python application startup time - DEV Community
This tells you the time for imports:
PYTHONPROFILEIMPORTTIME=True uv run my_program.py
Exclude directories when building UV packages
My package was 156mb because my tests/ were 120mb.
Uv uses hatchling
- Building and publishing a package | uv
- Build configuration - Hatch
- Feature request: Add ability to exclude certain file/directory patterns from
uv buildoutput · Issue #7938 · astral-sh/uv
TL;DR add this to pyproject.toml
[tool.hatch.build.targets.sdist]
exclude = [
"tests/"
]
Before/after:
# before
-rw-r--r-- 1 sh sh 156M Jul 13 13:20 pkg-9.2.0.tar.gz
# after
-rw-r--r-- 1 sh sh 8.3M Jul 13 13:15 pkg-9.3.0.tar.gz
# yay!