python -X importtime shows what makes a CLI slow to start
A command that takes 800ms before it prints its help is usually paying for imports, not for work. The interpreter itemises that for you.
python -X importtime -m mytool --help 2>&1 | sort -k5 -rn | headEvery import gets a line on stderr with its own time and the cumulative time of its subtree, so the sort puts the expensive branches on top. A heavy dependency that one subcommand needs belongs inside the function that uses it, and startup drops by what that subtree cost. PYTHONPROFILEIMPORTTIME=1 does the same without touching the command line.
pythonperformancedebugging