CMD + K

cppimport

Community

Import C++ directly from Python!

Installation

To install this package, run one of the following:

Conda
$conda install conda-forge::cppimport

Usage Tracking

26.4.17
22.8.2
2 / 8 versions selected
Downloads (Last 6 months): 0

Description

Sometimes Python just isn't fast enough. Or you have existing code in a C or C++ library. So, you write a Python extension module, a library of compiled code. I recommend pybind11 for C++ to Python bindings or cffi for C to Python bindings. I've done this a lot over the years. But, I discovered that my productivity is slower when my development process goes from Edit -> Test in just Python to Edit -> Compile -> Test in Python plus C++. So, cppimport combines the process of compiling and importing an extension in Python so that you can just run import foobar and not have to worry about multiple steps. Internally, cppimport looks for a file foobar.cpp. Assuming one is found, it's run through the Mako templating system to gather compiler options, then it's compiled and loaded as an extension module.

About

Summary

Import C++ directly from Python!

Last Updated

Apr 17, 2026 at 17:34

License

MIT

Supported Platforms

noarch