A module to enable lazy imports using native python syntax
Project description
Lazyimports
Overview 🌐
Lazyimports is a Python module that enables lazy imports using native Python syntax, reducing startup time and improving performance by delaying module loading until needed.
Installation 🔨
Install Lazyimports via pip:
pip install lazyimports
Usage 👍
1. Using a with Statement
Wrap imports in a with statement to enable lazy loading:
import lazyimports
with lazyimports.lazy_modules("package", "package.submodule"):
from package import submodule
submodule.hello()
2. Configuring via pyproject.toml
For package-based usage, define lazy-loaded modules in pyproject.toml:
Standard configuration:
[project.entry-points.lazyimports]
"my_package" = "package,package.submodule"
Poetry-based configuration:
[tool.poetry.plugins.lazyimports]
"my_package" = "package,package.submodule"
3. Using an Environment Variable (for Development)
Set an environment variable to enable lazy loading dynamically:
export PYTHON_LAZY_IMPORTS="package,package.submodule"
python script.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_lazy_imports-0.1.0.tar.gz.
File metadata
- Download URL: auto_lazy_imports-0.1.0.tar.gz
- Upload date:
- Size: 204.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb90ecaabe28f8486a91bf3341d602706534e9bc19f0c49d0783b0af4aa20d66
|
|
| MD5 |
e070f0a994ed0071f14535193744df8e
|
|
| BLAKE2b-256 |
b894b6009a18f474cedfbc4e3243d32b922105127775345d266623fbd25b15e0
|
Provenance
The following attestation bundles were made for auto_lazy_imports-0.1.0.tar.gz:
Publisher:
publish.yaml on hmiladhia/lazyimports
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
auto_lazy_imports-0.1.0.tar.gz -
Subject digest:
cb90ecaabe28f8486a91bf3341d602706534e9bc19f0c49d0783b0af4aa20d66 - Sigstore transparency entry: 168708125
- Sigstore integration time:
-
Permalink:
hmiladhia/lazyimports@0115bea1557248db6119a6bfbe5ddd97ef0f5c7e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hmiladhia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@0115bea1557248db6119a6bfbe5ddd97ef0f5c7e -
Trigger Event:
release
-
Statement type:
File details
Details for the file auto_lazy_imports-0.1.0-py3-none-any.whl.
File metadata
- Download URL: auto_lazy_imports-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5cbfafa91aad7cf7eb39c816987570a59d7f82c88aa8d22a052bf447107d94e
|
|
| MD5 |
5c51ab754e1638e0a302963ed5755b0f
|
|
| BLAKE2b-256 |
08d8369590d85a64f9af595091dfd7a12c7c85d6d5af4acb1492161068834994
|
Provenance
The following attestation bundles were made for auto_lazy_imports-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on hmiladhia/lazyimports
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
auto_lazy_imports-0.1.0-py3-none-any.whl -
Subject digest:
f5cbfafa91aad7cf7eb39c816987570a59d7f82c88aa8d22a052bf447107d94e - Sigstore transparency entry: 168708127
- Sigstore integration time:
-
Permalink:
hmiladhia/lazyimports@0115bea1557248db6119a6bfbe5ddd97ef0f5c7e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hmiladhia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@0115bea1557248db6119a6bfbe5ddd97ef0f5c7e -
Trigger Event:
release
-
Statement type: