Populate library namespace without incurring immediate import costs

PyPI

lazy-loader makes it easy to load subpackages and functions on demand.

Motivation

  1. Allow subpackages to be made visible to users without incurring import costs.
  2. Allow external libraries to be imported only when used, improving import times.

For a more detailed discussion, see the SPEC.

Installation

pip install -U lazy-loader

Usage

Lazily load subpackages

Consider the __init__.py from scikit-image:

subpackages = [
...,
'filters',
...
]

import lazy_loader as lazy
__getattr__, __dir__, _

 

To finish reading, please visit source site