Overall Winner
Django-Bolt
5 out of 7 scenarios
Best Performance
5.67x
Django-Bolt JSON Serialization
Iterations Tested
100,000
Per scenario (10,000 for errors)
Scenarios Tested
7
Covering all use cases
Operations Per Second Comparison
Relative Performance (Higher is Better)
Detailed Results
| Scenario | Django-Bolt (ops/sec) | Pydantic v2 (ops/sec) | Winner | Speedup |
|---|---|---|---|---|
| Dict → Object (No Validators) | 1,542,436 | 1,322,541 | Django-Bolt | 1.17x faster |
| JSON → Object (No Validators) | 1,659,432 | 1,043,189 | Django-Bolt | 1.59x faster |
| Object → Dict Serialization | 4,611,895 | 1,246,177 | Django-Bolt | 3.70x faster |
| Object → JSON Serialization | 6,678,476 | 1,177,411 | Django-Bolt | 5.67x faster |
| Dict → Object (With Validators) | 873,918 | 1,089,603 | Pydantic v2 | 1.25x slower |
| JSON → Object (With Validators) | 852,625 | 910,603 | Pydantic v2 | 1.07x slower |
| Validation Error Detection | 1,557,492 | 1,025,908 | Django-Bolt | 1.52x faster |
Key Findings
- Serialization Dominance: Django-Bolt excels at serialization tasks (Object → Dict/JSON), with up to 5.67x performance advantage
- JSON Processing: Django-Bolt is significantly faster at JSON operations, making it ideal for high-throughput API responses
- Custom Validators Trade-off: Pydantic v2 has a slight edge when custom field validators are involved (1.07-1.25x faster)
- Error Detection: Django-Bolt validates errors 1.52x faster, important for input validation scenarios
- Best Use Cases: Django-Bolt shines in API response serialization, Pydantic v2 in complex input validation with custom logic
Benchmark Methodology Notes
Current Issues:
- No warmup runs before timing (can include JIT/cache cold start overhead)
- Single run per test (no variance/standard deviation reporting)
- No statistical confidence intervals
- GC not disabled during benchmarks
- No CPU frequency scaling controls
Recommendation: Results are indicative but should include warmup, multiple runs, and statistical analysis for publication-grade benchmarks.
Summary & Recommendations
Django-Bolt (msgspec) is optimized for:
- High-throughput API response serialization
- JSON encoding/decoding operations
- Scenarios without complex custom field validators
- Performance-critical API endpoints (60k+ RPS)
Pydantic v2 excels at:
- Complex input validation with custom field validators
- Scenarios requiring extensive data transformation logic
- Applications prioritizing validation features over raw speed