FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

array-python-cpp/README.md at master · benjaminirving/array-python-cpp · GitHub

Latest commit

 

History

History
27 lines (17 loc) · 814 Bytes

File metadata and controls

27 lines (17 loc) · 814 Bytes

Python c++ interface example

This code illustrates how simple it is to pass n-dimensional (or in this case 2D) numpy arrays from python to c++ vectors and back.

Allowing computationally expensive code to be easily written in c++ and linked to high level python code.

This code is a small adaption from the Cython standard example (Wrapping c++) to also include the 2D numpy example

Requirements:

  • numpy
  • Cython

Rectangle.cpp and Rectangle.h is a an example c++ class to be wrapped

This is wrapped using cython with an interface file rect.pyx and compiled using setup.py in the standard cython way using the command:

Compiling the code:

python setup.py build_ext --inplace

Running the code:

python python_test.py

Back | FazBrowse Home | New Git URL