A lightweight and extensible way to implement lazy imports globally.
Project description
Lazi: Lazy Imports Everywhere
A lightweight and extensible way to implement lazy imports globally.
Usage:
poetry add lazi
"""Automatic lazy loading example.
Install django to run, or change the imports.
"""
import lazi.auto # Install import tracking.
import django.test # Import stuff.
print(lazi.used_count()) # Count loaded modules.
TestCase = django.test.TestCase # Trigger lazy loading.
print(lazi.used_count()) # More modules were lazy loaded.
python example.py
5
211
"""Manual lazy loading example.
"""
import lazi.core # Import Lazi.
django = lazi.lazy("django") # Import stuff.
django_test = lazi.lazy("django.test") # Import more stuff.
print(lazi.used_count()) # Count loaded modules.
TestCase = django_test.TestCase # Trigger lazy loading.
print(lazi.used_count()) # Module was lazy loaded.
1
2
Metadata
Reference for developers: The json dict below contains Python versioning parameters:
- Soft
min
(ignore rev) & hardmax
compatible versions. - Recommended
use
& creator's environmentdev
versions.
{
"python": {
"version": {
"min": "3.10.11",
"max": "3.12",
"use": "3.11",
"dev": "3.11.2"
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lazi-1.2.0.15.tar.gz
(18.0 kB
view hashes)
Built Distribution
lazi-1.2.0.15-py3-none-any.whl
(19.5 kB
view hashes)