🚀 Highlights & Performance Leap
⚡ Serialization Fast-Paths (Up to 24x Speedup)
- Concrete Type Fast-Paths: Direct CPython concrete type checking in Rust (
PyBool, PyLong, PyFloat, PyString, PyDict, PyList), eliminating thousands of internal AttributeError exceptions caused by dynamic hasattr checks.
- Primitives Serialization: Reduced from 118.4 ms down to 4.8 ms (~24x speedup).
- Nested Data Structures: Reduced from 408.2 ms down to 34.0 ms (~12x speedup).
- Simple Objects (10,000): Reduced from 4.83 ms to 2.01 ms (🚀 4.1x faster than orjson, 6.0x vs standard JSON).
🌊 Streaming Protocol Optimizations (2.1x Speedup)
- Streaming Decode (Aligned): 11.8 ms for 1,000 frames (~85,000 frames/s).
- Streaming Decode (Fragmented): 13.6 ms for 1,000 frames (~73,500 frames/s).
- Single Frame Latency: Reduced to 139.2 µs (+11.5% speedup).
- Sustained Stream Throughput: > 12,500 frames/s.
🐛 Critical Bugfix for Pydantic Models
- Fixed an issue where nested lists and dictionaries in Pydantic models (e.g.
scores: list[float]) fell back to 0x10 (None) in serialize_value_fast. They are now fully supported and accelerated.
🧠 Memory & Allocation Reductions
- Zero Allocations in Batch Lookups: Pre-collected
&PyAny key references in serialize_pydantic_simd_batch for direct pointer comparison and cached hash lookups in CPython.
- Pre-allocated String Table: Pre-allocates
PyString instances during decode_packed, eliminating tens of thousands of redundant string allocations per frame.
- Lazy Extended Types Loading:
datetime, date, time, UUID, and Decimal are now lazy-loaded on demand during decode, eliminating dynamic import overhead for standard payloads.
🏷️ Single Source of Truth (SSOT) Versioning
- Versioning is now centralized exclusively in
Cargo.toml.
- Python wheel building dynamically derives the version via Maturin (
dynamic = ["version"]).
- Python runtime exports
b_fast.__version__ directly from Rust compile-time metadata (env!("CARGO_PKG_VERSION")).
- TypeScript package provides
npm run sync-version to keep package.json synchronized.
📦 Installation
# Python
pip install bfast-py==1.5.0
# or
uv add bfast-py
# TypeScript
npm install bfast-client@1.5.0
🔗 Links