3 ms·
>Python imports and slow startup speed hurts Python developers on moderate and large projects What kloc is moderate and large? I have not run into a project wh
by fnord123 6y ago
>Python imports and slow startup speed hurts Python developers on moderate and large projects
What kloc is moderate and large? I have not run into a project where import took that long.
>I believe JS/TypeScript folks try to avoid this trap.
Have you ever had to run a node project? I haven't benched it but I think it would be faster to compile a rust project and start that up than use node. But I can't web so maybe there's special ways to make node start quickly that I just don't know about. (I think there's a law where you can get answers more quickly by declaring something impossible to trigger people into flooding you with great suggestions :-) ).
- fnord123 6y agoAh, maybe it's use of pkg_resources that you find to be a problem with imports. That's indeed a horror story especially with NFS mounted python files.
- twa927 6y agoThe problem I experienced multiple times in 50-200 KLOC projects is not the time needed to import the modules, but the memory consumption caused by the imports. Moving some imports from top-level module statements to inner functions' code could improve the memory consumption several times, e.g. from 250MB per process to 80MB per process. One tool I used was https://github.com/mnmelo/lazy_import https://github.com/mnmelo/lazy_import but I'm not sure it's updated for Python 3.7/3.8.