2 ms·
A big portion of python's slowness to start up is that 'import' actually evaluates any code at the top level of the file it's importing. If you just have funct
by ok123456 5y ago
A big portion of python's slowness to start up is that 'import' actually evaluates any code at the top level of the file it's importing.
If you just have function and class definitions, this isn't too bad, but when you start doing things like setting up caches, reading files, and testing whether or not there's a GPU at the top level, you can add several seconds to the startup and balloon your memory usage. One wrong import somewhere in your code base, and your application will craw to a standstill on launch.