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.2.tar.gz (10.3 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.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alenia_zenith-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for alenia_zenith-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9bb09408ecc79a41422db7d8cae889584313c603dd6cdaddecf6a7d1d68e0851
MD5 a06fc7d15e5ed45ee7501218c94ae95e
BLAKE2b-256 8d39abe977d34ed3c29e5f7872b8d7cad8c91c150b635b366f4544d55d44585f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: alenia_zenith-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for alenia_zenith-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85faa9564f04d2d8d39f79d87bdfb3bea34e3748348d9f2ae83367487d2d994d
MD5 9c89eb9ebf9dda3d73dd5cb5a727c6b3
BLAKE2b-256 6466a1cd773f974a020a1fd996cf110a3ab6c45c101e7c33c403c547f786a165

See more details on using hashes here.

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