You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,34 +146,42 @@ msgspec-ext leverages msgspec's high-performance serialization with bulk JSON de
146
146
147
147
| Library | Time per load | Relative Performance |
148
148
|---------|---------------|---------------------|
149
-
| msgspec-ext |2.271ms| Baseline ⚡ |
150
-
| pydantic-settings |6.157ms|2.7x slower |
149
+
| msgspec-ext |0.023ms| Baseline ⚡ |
150
+
| pydantic-settings |1.350ms|58.7x slower |
151
151
152
-
msgspec-ext is **2.7x faster** than pydantic-settings while providing the same level of type safety and validation.
152
+
**Cold Start vs Warm Performance:**
153
+
- Cold start: 1.489ms (1.3x faster than pydantic-settings)
154
+
- Warm cached: 0.011ms (117.5x faster than pydantic-settings)
155
+
- Internal speedup: 129.6x faster when cached
153
156
154
-
**Key optimizations:**
155
-
- Bulk JSON decoding in C (via msgspec)
156
-
- Cached encoders and decoders
157
-
- Automatic field ordering
158
-
- Zero Python loops for validation
157
+
msgspec-ext is **ultra-optimized** with advanced caching strategies:
158
+
- Field name to env name mapping cache
159
+
- Absolute path cache for file operations
160
+
- Type introspection cache for complex types
161
+
- Atomic encoder/decoder cache pairs
162
+
- Fast paths for primitive types (str, bool, int, float)
163
+
- Local variable caching in hot loops
159
164
160
-
*Benchmark measures complete settings initialization with complex configuration (app settings, database, redis, feature flags) including .env file parsing and type validation. Run `./benchmark/run_benchmark.sh` to reproduce.*
165
+
*Benchmark measures complete settings initialization with complex configuration (app settings, database, redis, feature flags) including .env file parsing and type validation. Run `./benchmark/benchmark.py` to reproduce.*
161
166
162
167
## Why msgspec-ext?
163
168
164
-
-**Performance** - 2.7x faster than pydantic-settings
169
+
-**Performance** - 117.5x faster than pydantic-settings when cached, 1.3x faster on cold start
0 commit comments