---
title: "Pydantic 2.0: Python validation rewritten in Rust"
description: "Pydantic 2.0 (June 2023) by Samuel Colvin: Python data validation with core rewritten in Rust (pydantic-core), 5-50x faster, native JSON Schema, custom serialisation. Foundation of FastAPI, SQLModel, LangChain."
url: "https://www.noze.it/en/insights/pydantic-2-0/"
lang: "en"
alternate: "https://www.noze.it/insights/pydantic-2-0/"
published: "2023-06-30"
author: "noze S.r.l."
keywords: "Open Source, R&D, Pydantic, Samuel Colvin, Python, Validation, Rust"
---

# Pydantic 2.0: Python validation rewritten in Rust

Pydantic 2.0 (June 2023) by Samuel Colvin: Python data validation with core rewritten in Rust (pydantic-core), 5-50x faster, native JSON Schema, custom serialisation. Foundation of FastAPI, SQLModel, LangChain.

30 June 2023

## Data-class-based Python validation

**Pydantic** — created by **Samuel Colvin** in 2017 — is a Python library for data validation via **type hints**. Type hints as validation schema instead of external JSON Schema. Becomes popular thanks to **FastAPI** adoption (Sebastián Ramírez, 2018) using it as foundation.

```
from pydantic import BaseModel, EmailStr
from datetime import datetime

class User(BaseModel):
    id: int
    name: str
    email: EmailStr
    created_at: datetime

user = User(id=1, name="Anna", email="anna@example.com",
            created_at="2023-01-15T10:30:00")
# Automatically validates types, parses datetime string, verifies email
```

## Pydantic 2.0 and Rust

Pydantic 2.0, released on **30 June 2023**, is a **core rewrite in Rust** via `pydantic-core` crate. Performance improvements of **5-50x** on validation. Python API remains mostly backward-compatible (with migration guide).

**MIT** licence.

## Functionality

- **Models** with type hints
- Custom **field validators**
- **Serialisers** (JSON, dict, custom)
- **Aliases** for field mappings
- Automatic **JSON Schema** generation
- **Generics** for parametric types
- **Strict mode** — no implicit coercion

## Dependent ecosystem

- **FastAPI** — request/response validation
- **SQLModel** (Sebastián Ramírez, 2021) — ORM based on Pydantic + SQLAlchemy
- **LangChain** — LLM structured output
- **Prefect**, **Argilla**, thousands of modern libraries

## In the Italian context

Pydantic is in the backend of every Italian FastAPI application; growing in ML/AI for LLM structured output.

---

_References: Pydantic 2.0 (30 June 2023). Samuel Colvin. MIT licence. Rust core rewrite (pydantic-core). Backward-compat API. Foundation of FastAPI, SQLModel, LangChain._
