Pydantic Validation is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain and others.
Pydantic uses Rust under the hood. This makes it faster than say, something implemented directly in Python.
How are the Python and Rust pieces glued together?
The key is that the validation layer is compiled in Rust (pydantic-core). Data parsing, validation and in general, any perf-critical operations, are done here. Py03 is used to create bindings in Python.
While there is no need to use the Rust code directly, for reference it can be found in GitHub here.
But what does this validation actually entail? What's the use case?
How does it work?
Type hints (PEP 484) are one of the tools used in Python validation (GvR himself h as co-authored that PEP). Type hints enable integration with various static typing tools (like mypy) and IDEs (like VSCode).
The Type hints PEP also references PEP 3107 for function annotations (written by Collin Winter and Tony Lownds).