Skip to main content

A deep infrastructure library for Python 3.14+ focused on extreme startup time optimization via lazy imports and speculative loading.

Project description

Zenith

Python Version License Status

Zero-latency boot infrastructure for Python applications.

Zenith is an advanced speculative execution pre-loader designed to eliminate Python's startup import latency. By leveraging Python 3.14's native free-threading model (PEP 703) and fully automated lazy loading, Zenith speculatively pre-loads heavyweight dependencies concurrently in background threads, enabling near-instantaneous application boot times.


Performance & Telemetry Benchmarks

Performance optimization is Zenith's core mission. The telemetry suite measures boot sequences using representative workloads (e.g., initializing multiprocessing, urllib.request, sqlite3, json, and parsed XML structures simultaneously):

Average Boot Speed Comparison

Load Phase Native Python Zenith (Warm Cache) Absolute Savings Relative Improvement
Boot Duration (s) ~0.150s ~0.040s 0.110s ~73.3% faster
Boot Duration (ms) ~150.0ms ~40.0ms 110.0ms ~73.3% faster

Note: Telemetry metrics are recorded on isolated subprocess iterations to prevent memory warm-up leakage.


Technical Deep Dive

Zenith accomplishes extreme startup optimization without requiring application code refactoring. It manages this through two specialized, low-level systems:

                  [Application Entrypoint]
                             │
                    ( zenith.ignite() )
                             │
            ┌────────────────┴────────────────┐
            ▼                                 ▼
   [sys.meta_path Interception]      [Background Thread Pool]
    - ZenithLazyFinder                - SpeculationEngine (Free-Threaded)
    - Returns ZenithLazyModule        - Pre-loads actual modules (GIL-free)

1. Interception Layer (sys.meta_path)

  • Custom MetaPathFinder (ZenithLazyFinder): Injected at index zero of sys.meta_path, this hook intercept all import requests.
  • Proxy Lazy Loading (ZenithLazyModule): Instead of executing synchronous, disk-bound imports, Zenith instantly returns a proxy module. The actual loading is postponed until an attribute of the module is actively accessed.

2. Speculative Execution (SpeculationEngine)

  • Background Pre-loading: Operating concurrently to your application's bootstrap phase, a persistent background thread (SpeculationEngine) proactively loads modules into memory.
  • PEP 703 Multi-threading: On Python 3.14+ free-threaded environments, this process runs on separate CPU cores completely free of the Global Interpreter Lock (GIL) overhead, avoiding main-thread performance degradation.

Telemetry Suite (zenith-check)

Zenith includes an integrated performance verification tool under examples/zenith_telemetry.py to allow engineers to measure latency in their specific hardware environments.

Running the Telemetry Script

To measure the millisecond savings on your system, execute:

python3 examples/zenith_telemetry.py

Expected Output Structure

=========================================
     ZENITH PERFORMANCE TELEMETRY        
=========================================
Running telemetry measurements...

-----------------------------------------
 METRIC          | NATIVE     | ZENITH   
-----------------------------------------
 Avg Boot (s)    | 0.06168s   | 0.00152s
 Avg Boot (ms)   | 61.68ms    | 1.52ms
-----------------------------------------
 Telemetry Result: Saved 60.16ms (97.5% faster)
=========================================

Installation

Please note that while the package is distributed as alenia-zenith on PyPI, the library is imported under the name zenith.

pip install alenia-zenith

Quick Start

Initialize Zenith at the absolute top of your entrypoint script:

import zenith
zenith.ignite()

# Your heavyweight imports (loaded lazily & speculatively in the background)
import pandas as pd
import numpy as np

Configuration & Cache Persistence

Zenith automatically establishes a local import registry file in your project's root:

  • .zenith_cache.json: Records module import sequences and dependencies during runtime. On subsequent boot cycles, the SpeculationEngine reads this cache to proactively queue modules on background threads, ensuring instant availability.

License

Distributed under the ALENIA STUDIOS TOOL LICENSE Version 1.0. See LICENSE for more information.

Project details


Download files

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

Source Distribution

alenia_zenith-0.1.5.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

alenia_zenith-0.1.5-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file alenia_zenith-0.1.5.tar.gz.

File metadata

  • Download URL: alenia_zenith-0.1.5.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alenia_zenith-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bd5beda6b7f6602e7d23b86ab03a49742c055330e8d9052de2293aebbee38fd5
MD5 df30bb260980c373c7506a48cf67181f
BLAKE2b-256 d8ae75ab370d6aace5757720e983a54c0b6fd1685e6bb7e45858e065356b6587

See more details on using hashes here.

Provenance

The following attestation bundles were made for alenia_zenith-0.1.5.tar.gz:

Publisher: publish.yml on Kaia-Alenia/Zenith

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

File details

Details for the file alenia_zenith-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: alenia_zenith-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alenia_zenith-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 20f5d2a31213e45933d03406f5cb1e3a85008d6503157ee22a5bc487d1765320
MD5 2adc8e4951bba87c1069d107d00a21f4
BLAKE2b-256 5832b5ff52e6b8c47f2d0c4162dcb795fca1467787f662d41440a5873559148f

See more details on using hashes here.

Provenance

The following attestation bundles were made for alenia_zenith-0.1.5-py3-none-any.whl:

Publisher: publish.yml on Kaia-Alenia/Zenith

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page