cppy
What it is and what it does
Cppy is a header-only C++ library designed to reduce boilerplate when writing Python extension modules in C++. Its core contribution is a PyObject smart pointer that automatically handles Python's reference counting semantics, eliminating manual Py_INCREF and Py_DECREF calls and reducing a common source of memory leaks in C++ extensions. The library also provides convenience methods for typical object operations, making the C++ code more idiomatic and less error-prone.
The package is distributed as a pure Python wheel containing the C++ headers, so installation is straightforward and has no compiled dependencies. It supports modern Python versions and is actively maintained. Developers use it by including the header in their C++ extension code and leveraging the smart pointer and utility methods to write cleaner, safer extension modules.
Use it for:
- Writing Python extension modules in C++ where automatic reference counting reduces memory management errors.
- Building performance-critical Python libraries that need C++ implementation with less boilerplate.
- Simplifying PyObject manipulation in C++ code by using convenience methods instead of raw CPython API calls.
- Maintaining C++ extensions across multiple Python versions with a consistent, version-agnostic wrapper.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Cppy is a C++ header library that simplifies writing Python extension modules by providing a PyObject smart pointer that automatically manages reference counting and offers convenience methods for common object operations.
Yes, if you are writing C++ Python extensions. Cppy is actively maintained, has no security vulnerabilities, uses a permissive BSD license, and solves a real pain point in extension development. The low install friction makes it a practical choice. If you are not writing C++ extensions, it has no value.
Install
cppy on PyPI
pip
pip install cppyuv
uv add cppypoetry
poetry add cppyInstalling cppy
Before you install
Low install friction with a pure wheel distribution. The package is actively maintained with recent commits and supports Python 3.7 through 3.13, though it requires setuptools as a runtime dependency.
License in practice
BSD permissive license allows use in commercial and proprietary projects with minimal restrictions, requiring only copyright notice and disclaimer retention.
Quickstart
# Install cppy
pip install cppy
# In your C++ extension code, include the header:
#include "cppy/cppy.h"
// Use the PyObject smart pointer:
cppy::py_ptr obj(PyList_New(0));
Requires a C++ compiler and Python development headers to build C++ extensions that use cppy.
Verify before relying
- Whether cppy provides additional convenience methods beyond reference counting that are commonly used in extension development.
- Performance characteristics or overhead compared to direct CPython API calls.
- Compatibility with alternative C++ binding frameworks or whether cppy is typically used standalone.
Package facts
| License | Copyright (c) 2014, Nucleic All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — setuptools |
| Maintenance | actively maintained — 549 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 684,160/month — #5,358 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cppy-1.3.1-py3-none-any.whl
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
pybind11pybind11 is a header-only C++ library that…
permissive · top 1,000 on PyPI
pybind11-globalA header-only C++ library that generates Python…
permissive · top 15,000 on PyPI
CppHeaderParserParses C++ header files and extracts their…
permissive · top 15,000 on PyPI
PyQt5-sipPyQt5-sip provides the runtime support module…
permissive · top 5,000 on PyPI
sipSIP generates Python bindings for C and C++…
permissive · top 15,000 on PyPI
PyQt6-sipPyQt6-sip provides the runtime support module…
permissive · top 5,000 on PyPI
recordclassRecordclass provides memory-efficient, mutable…
permissive · top 15,000 on PyPI
PyBindGenPyBindGen generates clean C or C++ code that…
copyleft · top 15,000 on PyPI
pyblock-builderPyBlock Builder provides Python classes and…
permissive · top 15,000 on PyPI
pyclibraryParses C header files and automates…
permissive · top 15,000 on PyPI