Skip to main content

lazysafe

safely adopt python 3.15 lazy imports.

why it exists

python 3.15 ships PEP 810 explicit lazy imports. lazy import json defers loading until first use. reported wins: ~2.9x faster startup for import-heavy applications.

the catch: laziness changes when import-time side effects run. some libraries depend on them. under lazy mode, programs break in confusing ways.

lazysafe answers that question empirically.

install

pip install lazysafe

quickstart

# see which imports are safe to make lazy
lazysafe analyze src/

# show all modules including safe ones
lazysafe analyze src/ --all

# save a JSON report
lazysafe analyze src/ --save report.json

what it does

lazysafe scans your Python source files and classifies every import statement by its side-effect risk:

finding meaning action
SAFE no side effects detected safe to make lazy
RISKY might have side effects investigate before lazy
UNSAFE side effect detected keep eager
UNKNOWN can't determine statically needs probing (v0.3.0)

side-effect rules

code what it detects confidence
SE01 module-level function calls 0.6
SE02 foreign attribute assignment (monkeypatching) 0.9
SE03 sys.path / sys.modules / os.environ mutation 0.95
SE04 atexit / signal / logging registration 0.85-0.9
SE05 module-level file I/O 0.8
SE06 framework registration decorators (2+) 0.5
SE07 importlib.import_module with computed names 0.9
SE08 try/except ImportError with fallback patches 0.7

what it does not do

  • runtime lazy-loading for older pythons (no backport of PEP 810)
  • patching third-party packages' code
  • function-level profiling (use Tachyon in 3.15)
  • general linting/formatting (use ruff)

requirements

  • python >= 3.11 (host running lazysafe)
  • target programs using lazy import semantics require python >= 3.15
  • linux, macos, windows

links

license

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lazysafe-0.1.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

lazysafe-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file lazysafe-0.1.0.tar.gz.

File metadata

  • Download URL: lazysafe-0.1.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lazysafe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c7dfda475e411d4cdcc5cb3e12f5ba0780da95f103f62d4950fd5ac23a7bf04
MD5 4734942fc8037578f43afffd1b0beb02
BLAKE2b-256 f8444aea52a46bc352ef6b429ea58b62f4fb5ba34b069cc4de98f87726ce0320

See more details on using hashes here.

Provenance

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

Publisher: release.yml on rahulXs/lazysafe

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

File details

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

File metadata

  • Download URL: lazysafe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lazysafe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1697b5881bed6e1b12201d7ab9e1b800f64cedad7c48b6cf363904a76cce7fe
MD5 ce8264ba45709afe7cb43e2d432650a2
BLAKE2b-256 dea75b730de326a9c06c77f761baeba9875ed25a5f2f3dcf86592c56f7768d28

See more details on using hashes here.

Provenance

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

Publisher: release.yml on rahulXs/lazysafe

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

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

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