python-importtime-optimization
Installation
SKILL.md
Python Importtime Optimization
Diagnose and fix slow Python package import times. Procedure distilled from the
llamabot case (litellm = 4.1s of a 4.7s import llamabot, 2026-08-16) and the
earlier uvicorn fix (PR #388).
Step 1: Profile with -X importtime
python -X importtime -c "import pkg" 2> profile.txt
sort -t'|' -k2 -rn profile.txt | head -30 # by cumulative time
- The cumulative column identifies the hogs; one heavy dependency (litellm: 4.1s) typically dominates the package total (4.7s).
- Interpreter startup + small deps account for the remainder (~0.6s) — don't chase those until the dominant cost is gone.