psycopg-c
PostgreSQL database adapter for Python -- C optimisation distribution
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- 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.
- Installation has high friction: it requires a C compiler and library headers to build from source.
License · maintenance · safety
LGPL-3.0-only (copyleft) — 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.
last release 2026-05-01 (105 days) · last repo commit 2026-08-01 · 2,473 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 943,615 downloads/mo, #4,672 on PyPI
Alternatives
Verify before relying
pip install "psycopg[c]"
import psycopg
conn = psycopg.connect("postgresql://user:password@localhost/dbname")- 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.
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 on it.
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
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.
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.
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")
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 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: CythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: DatabaseTopic :: Database :: Front-EndsTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python Modules |
Evidence: psycopg_c-3.3.4.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “psycopg c extension”
- psycopg-cpsycopg-c is an optional C-compiled optimization package for Psycopg…
- opentelemetry-instrumentation-psycopgAdds OpenTelemetry tracing instrumentation to psycopg database…
- psycopg-poolProvides a connection pool for Psycopg 3, managing reusable…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also psycopg-binary · psycopg · psycopg-pool · psycopg2-binary · psycopg2 · types-psycopg2 · django-db-geventpool · PyGreSQL · postgres · sqlalchemy-cockroachdb