psycopg-c
PostgreSQL database adapter for Python -- C optimisation distribution
What it is and what it does
psycopg-c is an optional compiled extension for Psycopg 3, the PostgreSQL database adapter for Python. It is not a standalone package but rather a performance-optimization layer that sits on top of the main adapter library. When installed, it replaces certain hot-path Python functions with C-compiled equivalents to reduce overhead during database operations.
The package is distributed separately because compilation requires build tools and system libraries that not all environments have available. The documentation explicitly recommends installing it via `pip install "psycopg[c]"` rather than directly, so that the version stays synchronized with your installed adapter version. If compilation fails due to missing prerequisites, the fallback is `psycopg[binary]`, which provides pre-built wheels.
Use it for:
- Accelerate database queries in production applications where round-trip latency or data marshalling is a bottleneck.
- Reduce CPU overhead in high-throughput data pipelines that execute many small queries or process large result sets.
- Optimize long-running ETL jobs that rely on the adapter for bulk data movement between PostgreSQL and Python.
- Speed up applications by compiling the adapter layer to reduce interpreter overhead.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
psycopg-c is an optional C-compiled optimization package for Psycopg 3 that speeds up database operations by replacing pure-Python components with compiled extensions.
Yes, if you have a C compiler and PostgreSQL development headers available and are using Psycopg 3 in a performance-sensitive application. Install via `pip install "psycopg[c]"` to keep versions synchronized. If compilation fails, fall back to `pip install "psycopg[binary]"` instead. The LGPL-3.0-only license requires source disclosure if you distribute the linked software, so verify your deployment model first.
Install
psycopg-c on PyPI
pip
pip install psycopg-cuv
uv add psycopg-cpoetry
poetry add psycopg-cInstalling psycopg-c
Before you install
Installation has high friction: it requires a C compiler and library headers to build from source. The package is actively maintained (last commit 2026-08-01, 105 days since release), but you should only install this directly if you understand the build prerequisites—the documentation recommends using `pip install "psycopg[c]"` instead, or falling back to `psycopg[binary]` if compilation fails.
License in practice
Licensed under LGPL-3.0-only (copyleft). If you distribute software that links this package, you must make your source code available under compatible terms; static linking or bundling may trigger copyleft obligations depending on your deployment model.
Quickstart
pip install "psycopg[c]"
import psycopg
conn = psycopg.connect("postgresql://user:password@localhost/dbname")
Requires a C compiler (gcc, clang, MSVC) and PostgreSQL development headers (libpq-dev or equivalent) installed on your system. If these are unavailable, use `pip install "psycopg[binary]"` instead.
Verify before relying
- Whether the C extension provides measurable performance gains for typical workloads compared to pure-Python alternatives.
- Whether pre-built binary wheels are available for your platform, or if local compilation is always required.
- How the package integrates with higher-level database libraries and ORMs.
Package facts
| License | LGPL-3.0-only (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 105 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 943,615/month — #4,672 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: psycopg_c-3.3.4.tar.gz
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
psycopg-binaryProvides compiled C optimizations for the…
copyleft · top 1,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
psycopg-poolProvides a connection pool for Psycopg 3,…
copyleft · top 1,000 on PyPI
psycopg2-binarypsycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
psycopg2PostgreSQL database adapter for Python that…
copyleft · top 1,000 on PyPI
types-psycopg2Provides type hints for psycopg2, enabling…
permissive · top 5,000 on PyPI
django-db-geventpoolProvides a gevent-based connection pool for…
permissive · top 15,000 on PyPI
PyGreSQLPyGreSQL is a Python interface to PostgreSQL…
unclear · top 15,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
sqlalchemy-cockroachdbA SQLAlchemy dialect that enables ORM and SQL…
permissive · top 5,000 on PyPI