by thayne · 1y ago · 0 comments
And that is actually a problem for more than just performance. In some cases, importing at the top might actually just fail. For example if you need a platform specific library, but only if it is running on that platform.
Probably because PEP 8 says
> Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants
I banished the worst/heaviest libraries to this list at my workplace and it's been really helpful at keeping startup times from regressing.
So, they agreed on a common system of linting error codes? Is that documented somewhere?