Or, on the assumption that you're willing to do work to support lazy loading, you move all of the global code bar imports into the init function, and then have the last line of your module be init().
Python programs are set to get faster startup times with PEP 810 "Explicit lazy imports," which allows scripts to defer loading imported libraries until they're actually needed rather than at startup.
Starting a Python application typically results in a flurry of imports as modules from various locations (and the modules they import) get added into the application process. All of that occurs before ...
Explore a atualização Python 3.15 com JIT aprimorado, carregamento lazy e UTF-8 padrão para mais desempenho e compatibilidade.