Serialization
Vorte provides a high-performance serialization layer powered by a native Rust engine with automatic fallback to orjson and the Python standard library. It supports multiple formats and lazy schema generation for zero-overhead startup.
FastSerializer
FastSerializer is the core serialization engine. It automatically selects the fastest available backend in this priority order:
| Backend | Performance | Requirements |
|---|---|---|
Rust native (vorte_serial) | Fastest | Rust 1.75+ compiled extension |
orjson | Very fast | pip install orjson |
stdlib json | Baseline | Built into Python |
Multi-Format Support
Beyond JSON, Vorte supports binary serialization formats for high-throughput and low-latency scenarios.
JSON
MessagePack
CBOR
Protobuf
Format Selection Table
| Format | Binary | Schema | Best For |
|---|---|---|---|
| JSON | No | Not required | Public APIs, web clients, debugging |
| MsgPack | Yes | Not required | Internal microservices, high throughput |
| CBOR | Yes | Not required | IoT, constrained environments, binary data |
| Protobuf | Yes | Required (.proto) | Contract-first APIs, cross-language systems |
Lazy Schema Generation
lazy_schema defers Pydantic model serialization schema generation until the first request. This dramatically reduces startup time for applications with many models.
Custom Serializers
Register custom encode/decode logic for specific types.
Content Negotiation
Vorte automatically selects the serialization format based on the request Accept header.
Performance Benchmarks
Serialization benchmarks for a typical API response payload (1 KB, 20 fields, nested objects):
| Backend | Encode (ops/sec) | Decode (ops/sec) |
|---|---|---|
| Rust native | 850,000 | 720,000 |
| orjson | 620,000 | 510,000 |
| stdlib json | 180,000 | 150,000 |