Self-contained example on the use of Pybind11
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Examples of C/C++ calls from Python using PyBind

If you need help, just send me a mail

For now on, there are two examples:

  • Example0: an example that I give on my website. It consists of a C++ wrapper with a function accepting two numpy arrays as input and returns an (dynamically created in C++) array that is the sum of both inputs. Interesting example related to Numpy, with a simple build command.
  • Example1: Acccepts a Numpy array, sends it to a C function that will loop through all elements of the array and print them. The interest of this example is the inclusion of C code and the build done with Python distutils through


** Example 0 **

cd example0

** Example 1 **

cd example1
python build_ext --inplace

This will build and copy it next to You can now run the code with