lazyplanet - Global backwards-compatible lazy module importing
Python 3.15 introduces "lazy" imports, where the import is not actually done until it is attempted to be used:
>>> lazy from tarfile import TarFile
In this author's opinion, lazy importing should be the default, and
lazyplanet allows for this, in a backwards-compatible way:
>>> from lazyplanet import lazyplanet
>>> lazyplanet()
>>> from tarfile import TarFile
>>> globals()["TarFile"]
<lazy_import 'tarfile.TarFile'>
>>> TarFile
<class 'tarfile.TarFile'>
>>> globals()["TarFile"]
<class 'tarfile.TarFile'>
However, if you would like to import a module immediately, you can
import it with gusto, using a context manager in your scope:
>>> from lazyplanet import lazyplanet
>>> gusto = lazyplanet(globals())
>>> from tarfile import TarFile
>>> with gusto:
... from zipfile import ZipFile
...
>>> globals()["TarFile"]
<lazy_import 'tarfile.TarFile'>
>>> globals()["ZipFile"]
<class 'zipfile.ZipFile'>
Again, lazyplanet is backwards-compatible with versions of Python
older than 3.15, where all modules will be imported immediately.
- Original idea: https://m29.us/@ryan/116700617415211850
- PEP 810: https://peps.python.org/pep-0810/
License
Copyright © 2026 Ryan Finnie ryan@finnie.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This document is provided under the following license:
SPDX-PackageName: python-lazyplanet
SPDX-PackageSupplier: Ryan Finnie <ryan@finnie.org>
SPDX-PackageDownloadLocation: https://forge.colobox.com/rfinnie/python-lazyplanet
SPDX-FileCopyrightText: © 2026 Ryan Finnie <ryan@finnie.org>
SPDX-License-Identifier: MIT
Metadata
Release files for lazyplanet 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lazyplanet-1.0.0.tar.gz | 3.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lazyplanet-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / lazyplanet-1.0.0.tar.gz
| Download URL | lazyplanet-1.0.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af7ef112e2469c0dad6e28fe2ccf15bd6feda1eb8d3a1fec37d98a4afd9247d2
|
|
BLAKE2b-256 checksum How to use checksums |
c02a1ba3dfd95e861f98239d0422b3dfff1c1f94fbc1f804272ffbb119b699b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / lazyplanet-1.0.0-py3-none-any.whl
| Download URL | lazyplanet-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65a49eeea75eb7088426fa3f1963326905fdb1d1a01f0ab3d029cbf1f72c1fd9
|
|
BLAKE2b-256 checksum How to use checksums |
2ffb00ab3efb5c674f1a207e1853a066503c9f0fd5157453c891dc8c3834ec2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for lazyplanet 1.0.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.