// the find
MagicStack/asyncpg
A fast PostgreSQL Database Client Library for Python/asyncio.
asyncpg is a native PostgreSQL binary protocol client for Python asyncio, built by the MagicStack team (same people behind EdgeDB). It bypasses DB-API entirely and implements the wire protocol in Cython, which is where the performance comes from. If you're running a Python async service that talks to Postgres and performance matters, this is the library to reach for.
Native binary protocol implementation in Cython — not a wrapper around libpq, so you avoid the C library overhead and get direct control over serialization. Prepared statement caching is automatic and transparent; the pool handles it per-connection without you thinking about it. First-class support for PostgreSQL-specific types (arrays, composite types, ranges, custom types) that DB-API drivers paper over with strings. The connection pool is genuinely well-designed — handles prepared statement invalidation on schema changes, which will bite you silently in psycopg2.
No DB-API 2.0 compatibility, which means most ORMs (SQLAlchemy classic style, Django ORM) won't work with it directly — SQLAlchemy has an asyncpg dialect but it's a thin shim and you lose some of the performance benefit. The Cython build step makes installation messier in constrained environments (Alpine containers, certain CI images) where you need gcc and Python headers. The 5x faster than psycopg3 benchmark is from 2023 and psycopg3 has closed some of that gap, especially with its own binary mode. No built-in migration tooling — you're expected to pair it with Alembic or handle migrations yourself.