Skip to content

Draft: Speedup imports

Tamas Gal requested to merge speedup-imports into master

The import time is quite huge already (6s) due to the unified namespace: every submodule is available when km3pipe is imported.

One way to improve it is to delay the imports using the __getattr__ and __dir__ on modules (introduced in Python 3.7), see https://snarky.ca/lazy-importing-in-python-3-7/

Or to not load any submodule, only when the user explicitly imports them. This however means that a import km3pipe as kp and subsequent access to submodules like kp.io.hdf5.HDF5Pump without any other imports will fail.

Merge request reports

Loading