Showing posts with label pydantic. Show all posts
Showing posts with label pydantic. Show all posts

Friday, 17 July 2026

More on Data Validation in Pydantic

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).

Friday, 23 January 2026

dataclasses in Python

Classes that hold data - cool, right? But boring to implement. Python dataclasses have the solution. But check too what Pydantic has to offer. They are described in PEP557.

What is Pydantic?

Pydantic is used in a number of Python frameworks and libraries - for example, it is used in Langchain extensively.

Pydantic is a widely used data validation library.  

It makes extensive use of the annotations feature in Python. It is worthwhile to understand them in the context of type hints.