demandimport
Delays loading of modules until they are actually used. Perfect for Python apps that need to be snappy like command-line utils. Source-code derived from mercurial.
To enable, write
import demandimport; demandimport.enable()
Imports of the following form will be delayed
import a, b.c
import a.b as c
from a import b, c # a will be loaded immediately, though
These imports with not be delayed
from a import *
b = __import__(a)
Delayed loading will confuse some third-party modules. In that case you can disable the delay for just that module. For example
demandimport.ignore('Crypto.PublicKey._fastmath')
There are also versions that can be used with with
with demandimport.enabled():
# do something
with demandimport.disabled():
import troublesome.module
with demandimport.ignored('test'):
import other.troublemaker
Installation
To install demandimport, simply run:
pip install demandimport
Attribution
Matt Mackall <mpm@selenic.com> is the original author of the module in Mercurial on which this module is based. Bas Westerbaan <bas@westerbaan.name> maintains it now.
py-demandimport Changelog
0.3.4 (2017-06-08)
Python 3.6
Add sip to the default ignore list. #6
0.3.3 (2016-10-20)
Add is_loaded and is_proxy. Thanks-to: github.com/poke1024
0.3.2 (2015-12-22)
Fixed issue #2: import a.b.c will incorrectly try to import b.c
0.3.1 (2015-12-21)
Relicense GPL version 2 or later (GPLv2+)
0.3.0 (2015-12-21)
Do not delay ImportError in a special case.
Add optional logging (for debugging)
Fixed issue #1: import a.b in a module a.c was incorrectly executed as a relative import c.
Improve thread safety
0.2.2 (2015-12-05)
Moved to zest.releaser
Add some basic unittests
Python 3 support
Metadata
Release files for demandimport 0.3.4
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 | Actions |
|---|---|---|---|---|
| demandimport-0.3.4.tar.gz | 12.9 kB | Without provenance | Details for demandimport-0.3.4.tar.gz |
Release files / demandimport-0.3.4.tar.gz
| Download URL | demandimport-0.3.4.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cb9f51a5e85aa7dd77acb4dcc2b3be8ead1472e90e64ea991875a06611dff8d
|
|
BLAKE2b-256 checksum How to use checksums |
8e947057121c217309e67cad655233c340a74fb5039cd9e98fb45849aedc1d29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for demandimport 0.3.4
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.