

#466: Pydantic Performance Tips
5 snips Jun 14, 2024
Sydney Runkle shares Pydantic performance tips to optimize code efficiency, covering techniques like using tag unions for discrimination in validation, efficient creation of type adapters, and strategies for importing code specifications. The discussion also explores discriminators for nested models, 'skip validation' annotations, and tools like CODSPEED for benchmark tests. Learn about Pydantic's impact on projects like FastAPI and the potential integration with large language models for enhanced productivity.
AI Snips
Chapters
Transcript
Episode notes
Open Source As A Career Springboard
- Sydney described joining Pydantic full-time after graduating and enjoying open-source work as a paid role.
- She recommends open-source contributions as a strong path into software development careers.
Rust Core Powers V2 Speedups
- Pydantic v2 moved core validation and serialization into Rust, producing 2–20x speedups versus the Python-only v1.
- The Python layer still defines schemas while Rust handles the heavy validation work.
Pydantic's Performance Impacts Many Projects
- Pydantic is widely used: hundreds of thousands of dependent projects and hundreds of millions of downloads.
- Improving Pydantic performance benefits a huge portion of the Python ecosystem.