--- id: cppy version: "1.3.1" 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) license_treatment: permissive maintenance: active --- # cppy License: permissive · Maintenance: active · Downloads: 684.2K/mo ## 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 above — 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 pip install cppy uv add cppy 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_current - Install friction: low - Maintenance: active - Downloads: 684.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python c++ extension development, pyobject smart pointer, reference counting wrapper, c++ python bindings, extension module helper, c++-bindings, extension-development [View on SkillFed](https://skillfed.io/packages/cppy) · [View on PyPI](https://pypi.org/project/cppy/)