Show HN: Importguard – Measure and enforce Python import-time behavior in CI
AryanKumar1401 Thursday, January 01, 2026I built a CLI tool to catch slow imports and sneaky side effects before they ship to production.
The problem: Python imports can quietly become a performance trap. Your CLI takes 2 seconds to show --help because importing your package pulls in pandas. Or worse, importing a module makes network calls or writes files as a side effect.
Importguard uses Python's -X importtime flag to measure exactly how long each import takes, then lets you:
- Set time budgets: `importguard check mypkg --max-ms 200` - Ban heavy imports: `importguard check mypkg.cli --ban pandas --ban torch` - Get reliable timing: `--repeat 5` runs multiple times and reports median - Configure per-module rules in `.importguard.toml`
It runs in an isolated subprocess so it doesn't pollute your interpreter, and outputs JSON for CI integration.
Use cases: - Keep CLI startup snappy - Prevent serverless cold start regressions (Lambda/Cloud Functions) - Ensure library hygiene (don't force users to install heavy deps)
pip install importguardpy
GitHub: https://github.com/AryanKumar1401/importguard
Happy to hear feedback on what would make this more useful!