Hacker News new | past | comments | ask | show | jobs | submit login

In really large projects (e.g. SciPy as mentioned in the article), lazy imports make sense. Especially with the popularity of decorators, importing a file without any apparent module-level code will actually need to run a nontrivial amount of code. Multiply that by a few thousand files in a library with a tree of "import * from ..." and you're looking at perhaps seconds of startup time. Lazy importing can short-circuit that, but still make symbols available for ease of use.



Numpy and Matplotlib were quite slow to import also, I haven’t timed them recently though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: