skillfed

cppy

cppy v1.3.1 684.2K downloads/30d#5,358 on PyPI89
Permissive 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) Active released

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 cppy

uv

uv add cppy

poetry

poetry add cppy

Installing 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

License :: OSI Approved :: BSD LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPython

Tags

python c++ extension developmentpyobject smart pointerreference counting wrapperc++ python bindingsextension module helper
c++-bindingsextension-development

More Software Development packages