Module load times

Joseph L. Casale jcasale at
Fri Aug 14 04:25:29 CEST 2015

> Importing is not the same as instantiation.
> When you import a module, the code is only read from disk and instantiated
> the first time. Then it is cached. Subsequent imports in the same Python
> session use the cached version.

I do mean imported, in the original design there were many ctype function
prototypes, the c developer had ran some tests and showed quite a bit of
time taken up just the import over 100 clean imports. I don't have his test
harness and hence why I am trying to validate the results.

> So the answer will depend on your application. If your application runs for
> a long time (relatively speaking), and imports the plugins 100s or 1000s of
> times, it should not matter. Only the first import is likely to be slow.
> But if the application starts up, imports the plugin, then shuts down, then
> repeats 100s or 1000s of times, that may be slow. Or if it launches
> separate processes, each of which imports the plugin.

Yeah that wasn't clear. The plugins are invoked in fresh interpreter processes
and hence modules with import side effects or simply large modules can
manifest over time.

Thanks Steven

More information about the Python-list mailing list