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
print(settings.features) # Automatically parsed from JSON string
139
147
```
140
148
141
149
## Why Choose msgspec-ext?
142
150
143
151
msgspec-ext provides a **faster, lighter alternative** to pydantic-settings while maintaining a familiar API and full type safety.
144
152
145
-
### Performance Comparison
153
+
### Performance Comparison (Google Colab Results)
146
154
147
-
**Cold start** (first load, includes .env parsing):
155
+
**Cold start** (first load, includes .env parsing) - *Benchmarked on Google Colab*:
148
156
149
157
| Library | Time per load | Speed |
150
158
|---------|---------------|-------|
151
-
|**msgspec-ext**|**0.39ms**|**5.0x faster** ⚡ |
152
-
| pydantic-settings |1.95ms| Baseline |
159
+
|**msgspec-ext**|**0.353ms**|**7.0x faster** ⚡ |
160
+
| pydantic-settings |2.47ms| Baseline |
153
161
154
-
**Warm (cached)** (repeated loads in long-running applications):
162
+
**Warm (cached)** (repeated loads in long-running applications) - *Benchmarked on Google Colab*:
155
163
156
164
| Library | Time per load | Speed |
157
165
|---------|---------------|-------|
158
-
|**msgspec-ext**|**0.012ms**|**267x faster** ⚡ |
159
-
| pydantic-settings |3.2ms| Baseline |
166
+
|**msgspec-ext**|**0.011ms**|**169x faster** ⚡ |
167
+
| pydantic-settings |1.86ms| Baseline |
160
168
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.*
169
+
> *Benchmark executed on Google Colab includes .env file parsing, environment variable loading, type validation, and nested configuration. Run `benchmark/benchmark_cold_warm.py`on Google Colab to reproduce these results.*
162
170
163
171
### Key Advantages
164
172
165
173
| Feature | msgspec-ext | pydantic-settings |
166
174
|---------|------------|-------------------|
167
-
|**Cold start**|**5.0x faster** ⚡ | Baseline |
168
-
|**Warm (cached)**|**267x faster** ⚡ | Baseline |
175
+
|**Cold start**|**7.0x faster** ⚡ | Baseline |
176
+
|**Warm (cached)**|**169x faster** ⚡ | Baseline |
169
177
|**Package size**|**0.49 MB**| 1.95 MB |
170
178
|**Dependencies**|**1 (msgspec only)**| 5+ |
171
179
| .env support | ✅ Built-in | ✅ Via python-dotenv |
@@ -180,25 +188,19 @@ msgspec-ext provides a **faster, lighter alternative** to pydantic-settings whil
180
188
msgspec-ext achieves its performance through:
181
189
-**Bulk validation**: Validates all fields at once in C (via msgspec), not one-by-one in Python
182
190
-**Custom .env parser**: Built-in fast parser with zero external dependencies (no python-dotenv overhead)
183
-
-**Smart caching**: Caches .env files, field mappings, and type information - loads after the first are 267x faster
191
+
-**Smart caching**: Caches .env files, field mappings, and type information - loads after the first are 169x faster
184
192
-**Optimized file operations**: Uses fast os.path operations instead of slower pathlib alternatives
185
193
-**Zero overhead**: Fast paths for common types (str, bool, int, float) with minimal Python code
186
194
187
195
This means your application **starts faster** and uses **less memory**, especially important for:
188
-
- 🚀 **CLI tools** - 5.0x faster startup every time you run the command
196
+
- 🚀 **CLI tools** - 7.0x faster startup every time you run the command
189
197
- ⚡ **Serverless functions** - Lower cold start latency means better response times
190
-
- 🔄 **Long-running apps** - After the first load, reloading settings is 267x faster (12 microseconds!)
198
+
- 🔄 **Long-running apps** - After the first load, reloading settings is 169x faster (11 microseconds!)
191
199
192
200
## Contributing
193
201
194
202
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
195
203
196
204
## License
197
205
198
-
MIT License - see [LICENSE](LICENSE) file for details.
0 commit comments