PEP 810 was accepted, bringing lazy imports to Python 3.15. This post explores how lazy imports benefit CLI tools—especially those with subcommands—by deferring module loading until actually needed, improving startup time. The challenge is that reification (triggering the actual import) happens on assignment, which breaks the
•3m read time• From snarky.ca
Table of contents
How to make subcommands work with argparseWhy these approaches don't work with lazy importsSome solutions to this problemSort: