Eagerly Load Python Modules#

Synopsis#

Load all ITK Python modules at once on import.

Results#

Output:

ITK namespace has 4045 symbols

Code#

Python#

#!/usr/bin/env python

### ITK Python Eager Loading

# By default ITK loads modules lazily, i.e. only when a class from
# the given module needs to be used.
# It can sometimes be useful to disable lazy loading
# so that modules load eagerly, i.e. all modules load as soon as
# `import itk` is run.

import itkConfig

itkConfig.LazyLoading = False

# This statement will now load all ITK modules at once
import itk

print(f"ITK namespace has {len(dir(itk))} symbols")