Skip to main content

A module to enable lazy imports using native python syntax

Project description

Lazyimports

logo

PyPI PyPI - License PyPI - Wheel Tests Copier Ruff

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

auto_lazy_imports-0.1.0.tar.gz (204.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_lazy_imports-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

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

Hashes for auto_lazy_imports-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb90ecaabe28f8486a91bf3341d602706534e9bc19f0c49d0783b0af4aa20d66
MD5 e070f0a994ed0071f14535193744df8e
BLAKE2b-256 b894b6009a18f474cedfbc4e3243d32b922105127775345d266623fbd25b15e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for auto_lazy_imports-0.1.0.tar.gz:

Publisher: publish.yaml on hmiladhia/lazyimports

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auto_lazy_imports-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_lazy_imports-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5cbfafa91aad7cf7eb39c816987570a59d7f82c88aa8d22a052bf447107d94e
MD5 5c51ab754e1638e0a302963ed5755b0f
BLAKE2b-256 08d8369590d85a64f9af595091dfd7a12c7c85d6d5af4acb1492161068834994

See more details on using hashes here.

Provenance

The following attestation bundles were made for auto_lazy_imports-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on hmiladhia/lazyimports

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page