python.
A complete site for FastAPI + Pydantic + uv — from setup to production-ready.
Articles
17 postsA Vyth's Note about: How to Select a Chunking Strategy for a RAG System
A field guide to the four main chunking strategies for a RAG system — fixed-size, structural, semantic, and by file type — with a rule of thumb for choosing one.
3 minhttpx AsyncClient pool limits keepalive tuning
Tune `httpx.Limits(max_connections, max_keepalive_connections, keepalive_expiry)` per upstream — the defaults (100 / 20 / 5s) leak idle sockets under burst traffic, so size keepalive to match downstream concurrency and shorten expiry behind aggressive load balancers.
9 minasyncio TaskGroup vs gather: Error Handling
55 minuv Dependency Groups (PEP 735) vs Poetry
56 minPydantic v1 — historical, do NOT copy into v2 verbatim
11 minfastapi-streaming-client-disconnect-cleanup
11 minFastAPI async SQLAlchemy pool_pre_ping pool_recycle production
Tune `AsyncAdaptedQueuePool` with `pool_size=20`, `max_overflow=0`, `pool_pre_ping=True`, `pool_recycle=3600` under sustained FastAPI load — covers the mid-transaction disconnect that pre-ping cannot rescue and when to fall back to `NullPool` on serverless.
11 minFastAPI Lifespan vs Startup/Shutdown: A Migration Guide That Won't Silently Break
Replace deprecated on_startup and on_shutdown handlers with FastAPI's lifespan async context manager. Covers stacking, exception propagation, and the silent-fail trap that catches most migrations.
9 minFastAPI TestClient vs httpx.AsyncClient: When You Actually Need Async Tests
A practical comparison of FastAPI's sync TestClient and httpx.AsyncClient with ASGI transport, including fixture patterns and when each one is the right call.
5 minMocking AsyncAnthropic in pytest: autospec, Response Stubs, and Streaming
Mock the async Anthropic Python SDK in pytest with autospec=True, typed response stubs for messages.create, and async-iterator stubs for streaming completions.
5 minFastAPI Request-ID Middleware: Correlation Across Upstream Services
Build a request-id + structured logging middleware in FastAPI using contextvars, a JSON formatter, and propagation rules that survive async hops and outbound httpx calls.
6 minPydantic Settings v2: Layered Env Config Without the Boilerplate
Build env-driven config in Python with Pydantic Settings v2 — nested models, layered .env overrides, validation, and secret types that survive logs.
6 min