Python Debugging Cheat Sheet/Profile import time

See which imports are slowing startup.

Section: Async, Web, and Production Troubleshooting

Profile import time

bash
bash
python -X importtime app.py

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Async, Web, and Production Troubleshooting
Enable asyncio debug mode
Expose slow callbacks and event-loop issues.
OpenIn sheetbashsame section
Enable debug mode programmatically
Turn on event loop debugging in code.
OpenIn sheetpythonsame section
Start a simple HTTP server for quick testing
Serve files locally to reproduce client behavior.
OpenIn sheetbashsame section
Dump stack traces for all threads
Useful when an app appears hung or deadlocked.
OpenIn sheetpythonsame section
Sort cProfile output by total time
Surface slow functions first.
OpenIn sheetbash1 tag match
Time a block of code
Measure elapsed time around suspicious code paths.
OpenIn sheetpython1 tag match