Skip to main content

lazy-loading

lazy-loading is a simple lazy module loader for python.

Usage:

First, you'll need to import lazy-loading.

To lazily load a package, use:

package = lazy-loading.lazyload("package")

You can lazily load submodules of your package:

lazy-loading.lazyload("mypacakge.submodule")

IDE autocompletion & type-checking

To get type-checking and autocompletion, you need to import all lazy-loaded packages if typing.TYPE_CHECKING is True:

from lazy-loading import lazyload
from typing import TYPE_CHECKING

lazyload("package1")
lazyload("package2")

if TYPE_CHECKING:
    import package1
    import package2

This will only run if a type-checker or linter is checking your code and will not cause packages to not lazy load in normal contexts.

Limitations:

Partial lazy loading

Partial lazy loading (e.g. from package import symbol) is not supported. Accessing an attribute or function will automatically import the entire module.

Relative imports

As mentioned previously, relative imports are not supported. You can lazy-load modules in your script's directory:

lazy-loading.lazyload("module")

If you are building a package:

lazy-loading.lazyload("package.module")

Lazily-loaded module dependencies

Imports called by lazily-loaded modules will not be lazy-loaded (unless the module uses lazy loading itself.)

Global name injection

Global name injection is not supported. You'll need to set a variable to the returned lazy-loaded package. It will replace itself with the lazy-loaded package when a symbol is accessed.

  • Removed global name injection because it doesn't work in most contexts and can cause a security risk

Full Changelog: https://github.com/yesser-studios/lazy-loading/commits/0.2.0

Metadata

Release files for lazy-loading 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lazy-loading 0.2.0
File Size Uploaded Provenance Actions
lazy_loading-0.2.0.tar.gz 5.1 kB Without provenance Details for lazy_loading-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lazy-loading 0.2.0
File Interpreter ABI Platform Actions
lazy_loading-0.2.0-py3-none-any.whl Python 3 none any Details for lazy_loading-0.2.0-py3-none-any.whl

Total release size: 11.7 kB

Release files / lazy_loading-0.2.0.tar.gz

Download URL lazy_loading-0.2.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
de48de022250f17497e3ff40bbeaa5e8b0c65a555d492d23021e8731435a23d1
BLAKE2b-256 checksum
How to use checksums
92c518c895a48be169fc9aa1af4d2fc244035b24bf31db70cb93e62f26528470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lazy_loading-0.2.0-py3-none-any.whl

Download URL lazy_loading-0.2.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9982d66e9d8d6d685be8d8980b14b8bd4c3506c66365de4eec2cff2ad6a75c10
BLAKE2b-256 checksum
How to use checksums
389025d4466a7d583ca6816ea43d6b33f2e783fd1455870f5d148a9ab5a1475e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for lazy-loading 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page