Talks: Pydantic Power-up: Performance Tips for Lightning-Fast Python Applications

Friday - May 17th, 2024 2:45 p.m.-3:15 p.m. in Ballroom BC

Presented by:


Pydantic is the most widely used data validation library for Python. With the V2 release, the library shifted to using Rust for core validation logic, which resulted in 5-50x speedups compared to V1. Though Pydantic is already quite efficient, there are some little-known performance tips and tricks you can use to ensure optimal performance.

In this talk, I’ll delve into a spectrum of optimizations, ranging from one line fixes to larger scale design modifications that can help you squeeze the best performance out of Pydantic. In terms of one line fixes, I’ll suggest changes ranging from opinionated JSON loading syntax to TypeAdapter usage tips. The focal point of the talk will be tagged (also called discriminated) unions, a Pydantic tool used to efficiently validate union types, while also taming related validation errors.

Listeners will walk away from this talk with a more nuanced understanding of performance with Pydantic, an abundance of examples that they can apply to their own code, and insights into upcoming performance enhancing features coming to Pydantic.