skillfed

psycopg-c

PostgreSQL database adapter for Python -- C optimisation distribution

psycopg-c v3.3.4 943.6K downloads/30d#4,672 on PyPI2,473
Copyleft license LGPL-3.0-only Active released

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-c

uv

uv add psycopg-c

poetry

poetry add psycopg-c

Installing 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

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

Tags

psycopg c extensionpostgresql python performancepsycopg optimizationcompiled database adapterpsycopg speeduppostgresql c bindingspsycopg3 performance boost
performance-optimizationc-extensionpostgresql

More Software Development packages

Further reading