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
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,55 +138,55 @@ class AppSettings(BaseSettings):
138
138
AppName: str# Exact match required
139
139
```
140
140
141
-
## Performance
141
+
## Why Choose msgspec-ext?
142
142
143
-
msgspec-ext leverages msgspec's high-performance serialization with bulk JSON decoding for maximum speed.
143
+
msgspec-ext provides a **faster, lighter alternative** to pydantic-settings while maintaining a familiar API and full type safety.
144
144
145
-
**Benchmark Results** (Python 3.12):
145
+
### Performance Comparison
146
146
147
-
| Library | Time per load | Relative Performance |
148
-
|---------|---------------|---------------------|
149
-
| msgspec-ext | 0.023ms | Baseline ⚡ |
150
-
| pydantic-settings | 1.350ms | 58.7x slower |
147
+
**First-time load** (what you'll see when testing):
151
148
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
149
+
| Library | Time per load | Speed |
150
+
|---------|---------------|-------|
151
+
|**msgspec-ext**|**1.818ms**|**1.5x faster** ⚡ |
152
+
| pydantic-settings | 2.814ms | Baseline |
156
153
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
154
+
**With caching** (repeated loads in long-running applications):
164
155
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.*
156
+
| Library | Time per load | Speed |
157
+
|---------|---------------|-------|
158
+
|**msgspec-ext**|**0.016ms**|**112x faster** ⚡ |
159
+
| pydantic-settings | 1.818ms | Baseline |
166
160
167
-
## Why msgspec-ext?
161
+
> *Benchmark includes .env file parsing, environment variable loading, type validation, and nested configuration (app settings, database, redis, feature flags). Run `benchmark/benchmark_cold_warm.py` to reproduce.*
168
162
169
-
-**Performance** - 117.5x faster than pydantic-settings when cached, 1.3x faster on cold start
0 commit comments