The Axiom

Python

8 pages

Start here

Hub

Python Brain

Central hub for all Python-specific knowledge. Covers the production AI Python stack — async I/O, data tooling, structured outputs, packaging, CLI frameworks, and testing.

Async Python Latency Benchmarking

Benchmark p50/p95/p99 with 1000+ samples per scenario. Use py-spy for sampling profiling without code changes. Histograms over averages — averages hide the tail. Profile representative traffic at steady state.

latencybenchmarkingp50p95

instructor — Structured LLM Outputs

instructor wraps the Anthropic and OpenAI clients to enforce Pydantic schema validation on every LLM response, with automatic retry on validation failure.

structured-outputspydanticinstructorllm-patterns

Polars + DuckDB

The two workhorses of Python data processing for AI engineers. Polars is a DataFrame library (pandas replacement) built on Apache Arrow — lazy evaluation, parallel by default, no GIL.

polarsduckdbdataframesanalytics

PyPI Distribution and Packaging

PyPI Trusted Publishers (OIDC) eliminates long-lived API tokens from CI — GitHub proves to PyPI it's running your workflow. Pytest plugins register via entry_points in pyproject.toml. No passwords stored, tokens expire automatically.

pypipackagingtrusted-publishersoidc

Python Async Programming

Python async/await is cooperative multitasking on a single thread — critical for LLM API calls, streaming, and any I/O-bound AI workload where waiting for a model response shouldn't block other work.

asyncasynciopythonconcurrency

Python Ecosystem for AI Engineers

Production AI Python stack — uv for packaging (10-100x faster than pip), AsyncAnthropic + httpx for async I/O, Pydantic v2 for validation, respx for mock testing, polars for dataset work.

pythonasyncpydanticclick

SQLAlchemy 2.0

Python's standard ORM and SQL toolkit. Version 2.0 (2023) introduced fully type-annotated models via `Mapped[T]` + `mapped_column()`, a unified `select()` API, and first-class async support.

sqlalchemyormasyncpostgresql