Skip to content

🏎️ L0-Python 0.19.0 - Performance Improvements

Choose a tag to compare

@LZL0 LZL0 released this 13 Dec 23:58

This release introduces optimizations to our core drift detection logic and updates our event tracing system for better performance.


πŸš€ Performance Improvements

Drift detection has been significantly optimized by pre-compiling all regex patterns and removing repeated per-check compilation. This reduces overhead across tone, format, repetition, markdown, and hedging detection while preserving identical behavior. The changes are entirely internal but materially improve throughput under high-token streaming workloads.


🧭 Deterministic Callback IDs (UUIDv7)

Guardrail and observability callbacks now use UUIDv7-based IDs instead of UUIDv4. UUIDv7 is time-ordered and faster to generate, improving traceability and event ordering in high-concurrency and distributed systems while maintaining global uniqueness.


πŸ”₯ Benchmark Results

Test Environment

  • CPU: Apple M1 Max (10 cores)
  • Runtime: Python 3.13, pytest 9 with pytest-asyncio 1.3.0
  • Methodology: Mock token streams with zero inter-token delay to measure pure L0 overhead
Scenario Tokens/s Avg Duration TTFT Overhead
Baseline (raw streaming) 1,518,271 1.32 ms 0.02 ms -
L0 Core (no features) 551,696 3.63 ms 0.08 ms 175%
L0 + JSON Guardrail 469,922 4.26 ms 0.07 ms 223%
L0 + All Guardrails 367,328 5.44 ms 0.08 ms 313%
L0 + Drift Detection 119,758 16.70 ms 0.08 ms 1166%
L0 Full Stack 108,257 18.48 ms 0.07 ms 1301%

πŸ“¦ Installation

pip install ai2070-l0
# or
pip install ai2070-l0[openai]
pip install ai2070-l0[litellm]