Skip to content

A collection of examples to wrap C++-Code using Cython to be able to use it within Python

Notifications You must be signed in to change notification settings

bam098/cython_wrapping

Repository files navigation

Cython Wrapping

A collection of examples to wrap C++-Code using Cython to be able to use it within Python.

Prerequisites

  1. Create a virtual Python environment (e.g. using conda)
    conda create -n wrapper Python=3.7

  2. Inside the created environment install the required packages
    conda activate wrapper
    conda install -c anaconda pip
    pip install -r requirements.txt

  3. Go to one of the subdirectories (e.g. 01_simple_c_wrapper) and follow the steps there (stay in the wrapper virtual environment).

The code has been tested on MacOS (10.9) and Linux (Ubuntu 18.04 LTS).

01 Simple C Wrapper

Wrapping a function in C that takes a string and prints that string on the console.

References:

02 Simple C++ Wrapper

Wrapping a function in C++ that takes a string and prints that string on the console.

References:

03 C++ Array Wrapper

Wrapping a function in C++ that takes an array and a number and multiplies that number to each element of the array.

References:

04 C++ Class Wrapper

Wrapping a class in C++ that encapsulates an array and provides various functions to handle that array (sum of its elements, getting array length, getting array itself, multiplying each element by a constant).

References:

05 C++ MultiClass Wrapper

Wrapping multiple class in C++. Again, we have one class that encapsulates an array. Furthermore, we have another class that takes a constant as input and offers a function which takes a vector class and multiplies each element of the vector class by the constant.

References:

06 C++ Dependency Wrapper

Wrapping a class in C++ that encapsulates an array and provides various functions to handle that array (sum of its elements, getting array length, getting array itself, multiplying the array with another array). Internally the C++ class uses OpenCV as external library.

References:

07 Wrapper Package

Creating a package called pymath containing a regular Python class and a Cython class that wraps a C++ class. The package can be installed using pip.

References:

About

A collection of examples to wrap C++-Code using Cython to be able to use it within Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published