I've started to play with lazy imports thanks to my WASI build script being in CPython's repo, and so I wrote a post about how to adapt your code for running subcommands with argparse to play nicely with lazy imports.
CLI subcommands with lazy imports
In case you didn't hear, PEP 810 got accepted which means Python 3.15 is going to support lazy imports! One of the selling points of lazy imports is with code that has a CLI so that you only import code as necessary, making the app a bit more snappy
snarky.ca · Tall, Snarky Canadian
Link author:
Brett Cannon@brettcannon@mastodon.social