laziness
Arbitrary lazy objects for Python 3.15 and above.
Installation
pip install laziness
Usage
lazy
lazy takes a positional string argument. It returns a special object that
will evaluate the string as a Python expression when accessed. For example:
>>> from laziness import lazy
>>> foo = lazy("print(42) or 24")
>>> # foo has not been evaluated yet...
>>> foo
42
24
>>> # Evaluation only happens once
>>> foo
24
lazify
lazify is similar to lazy, but instead of taking a string for the source,
it takes a callable. This callable is then invoked when the lazy object is accessed.
For example:
>>> from laziness import lazify
>>> foo = lazify(lambda: print(42) or 24)
>>> foo
42
24
>>> foo
24
Example
from laziness import lazy, lazify
def expensive_work():
import time
time.sleep(1)
return 42
EXPENSIVE_CONSTANT = lazy("expensive_work()")
EXPENSIVE_CONSTANT_ALT = lazify(lambda: expensive_work())
def public_function():
# EXPENSIVE_CONSTANT is not evaluated until this function is called
print(EXPENSIVE_CONSTANT)
How it works
Python 3.15 introduces lazy imports.
In CPython, this is implemented through a custom type that calls __import__
upon global lookup. This library builds on that functionality and takes it a
step further; instead of just calling __import__, you can call anything!
License
laziness is distributed under the terms of the MIT license.
Release files for laziness 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| laziness-0.1.3.tar.gz | 5.2 kB | Details |
Built distributions (wheels)
Total release size: 72.9 kB
Release files / laziness-0.1.3.tar.gz
| Download URL | laziness-0.1.3.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1697ecd1f699f7de4b284ed1df0383954392a8e2c649e76ece88e0cde7cde8ee
|
|
BLAKE2b-256 checksum How to use checksums |
3f00310be62f9e87f58b8d6369fde0b1fbb9b604e1bd3c478c7b3c7c96e99e13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-win_arm64.whl
| Download URL | laziness-0.1.3-cp315-cp315-win_arm64.whl |
|---|---|
| Size | 8.7 kB |
| Tags | CPython 3.15 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
57556d259bb3cb1721831a06eb5de0ad39b7081799460c906a44278994edcf5f
|
|
BLAKE2b-256 checksum How to use checksums |
43febb07d61e52e5483d3ad51fa71995397d602114182c8cf3a563db9e16fa74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-win_amd64.whl
| Download URL | laziness-0.1.3-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 9.1 kB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
128e8372c7999b2b4befeddd3ff90c44889316953deacdd888c01dd650cc213a
|
|
BLAKE2b-256 checksum How to use checksums |
ccf11fdb0979e3dcd3bed825d00d9262e973756f6fc09304a4042e6d95adfa5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-win32.whl
| Download URL | laziness-0.1.3-cp315-cp315-win32.whl |
|---|---|
| Size | 8.9 kB |
| Tags | CPython 3.15 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
86c932f33c375935f50fdd5bcda7cf30b1c88324242cf2d68d0aeea7596a9464
|
|
BLAKE2b-256 checksum How to use checksums |
bbf8ec54a0e8e0db60fd88847d3a643c6a1dee8a6b5f142a546c423a310d86de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-musllinux_1_2_x86_64.whl
| Download URL | laziness-0.1.3-cp315-cp315-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.0 kB |
| Tags | CPython 3.15 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
d8e2418fab25ba5b2747add7fcc998b4a88ea39c2c7ebe944eb932eb300c75fa
|
|
BLAKE2b-256 checksum How to use checksums |
25b175418ff654a3e7d86eedadb5605c94974804ca05ddb2a124c13c80467471
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-musllinux_1_2_aarch64.whl
| Download URL | laziness-0.1.3-cp315-cp315-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.1 kB |
| Tags | CPython 3.15 Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
83e38ce945bc84e0c5de939b0633d243e365242ed15367ca4b1bef620f8a6f2a
|
|
BLAKE2b-256 checksum How to use checksums |
985694e1846a58a5f05f71905d7e2c77a47709a2359e31f4479717588899c83b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | laziness-0.1.3-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.4 kB |
| Tags | CPython 3.15 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
8d861258a2e47589777a97c13b2fbc591d4923bf67d878c5792889636c242eab
|
|
BLAKE2b-256 checksum How to use checksums |
960cc9c511d2dc9652eb4175eb1d48d54cd6a35685487d5bbd7d854c1f7bb67e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | laziness-0.1.3-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 7.0 kB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
a0c9749a4911a2bd9dbb87410a862a280d6062d0ad8cdd74879c6079596a784a
|
|
BLAKE2b-256 checksum How to use checksums |
9578f6a40f1d729447e46726c69eef9e1083b8194cdd7c92c11199fac8454f56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-macosx_11_0_arm64.whl
| Download URL | laziness-0.1.3-cp315-cp315-macosx_11_0_arm64.whl |
|---|---|
| Size | 6.5 kB |
| Tags | CPython 3.15 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aefd5ea489e40d4a37475dbae6e10e5b4201a4c3575a38780a971bd57db0d26c
|
|
BLAKE2b-256 checksum How to use checksums |
ecc38d4b9c73e0dd4b76eea7588b3d2dee21e549d5b78ebae83f449c82720b1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / laziness-0.1.3-cp315-cp315-macosx_10_15_x86_64.whl
| Download URL | laziness-0.1.3-cp315-cp315-macosx_10_15_x86_64.whl |
|---|---|
| Size | 6.1 kB |
| Tags | CPython 3.15 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
8395bf15e65036c00440d03c1edcc3db5cc4501bcbdba4f692ee4dfbe82fd91e
|
|
BLAKE2b-256 checksum How to use checksums |
77997c0f02663995277e386636e98e1d401bf568eda15852bf00130da71ad50d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency log