3 ms·
Python avoids having to rerun the import over and over again. Suppose that you are importing a larger project. Where your one import (say of your standard dat
by btilly 5y ago
Python avoids having to rerun the import over and over again.
Suppose that you are importing a larger project. Where your one import (say of your standard database interface) pulls in a group of modules (say one for each table in your database), all of which import a couple of base libraries (to make your database objects provide a common interface) that themselves pull in common Python modules (like psychopg2) which themselves do further imports of standard Python modules.
The combinatorial explosion of ways to get to those standard Python modules would make the redundant work of parsing them into a significant time commitment without a caching scheme.
From the point of view of a small script, this kind of design may seem like overkill. But in a large project, it is both reasonable and common.
- AlphaSite 5y agoYep. Rerunning things is how you end up with C/C++ style headers and all the (performance and otherwise) problems there in.