dantrim / hamming-codec

Simple encode/decode utilties for bit-error correcting Hamming codes
MIT License
14 stars 4 forks source link

Move to C++ algorithm implementation and python bindings from C++ to python #9

Closed dantrim closed 3 years ago

dantrim commented 3 years ago

What

This PR adds the hamming encoding/decoding algorithm in C++. From the python side, then, pybind11 is used to create bindings to the C++ encoding/decoding methods, as opposed to the other way around which was there previously (mostly just to see that such a direction could be achieved via pybind11).

scikit-build

The Python build now leverages scikit-build to compile the source code and install the package and create the hamming command-line entrypoint.

Installation Changes

Python installation is unchanged, and is achieved via pip:

pip install .

The C++ installation is now more robust, given that the algorithm is entirely within C++ and pybind11 is not used to call the Python interpreter from within C++ code. Compilation follows the usual C++ CMake procedure:

mkdir build
cd build
cmake ..
make

The C++ build creates a shared library hamming_codec that can be linked against if one wants to use this in C++ code.

The C++ executables for encoding and decoding are now placed under an examples directory, showing how one can link to the hamming_codec library.