Exercise 1: binding classes and magic methods
Provide Python bindings using pybind11 for the code provided as the solution to exercise 1 from session 03.
- Bind the
DataProcessor
class and its member functions. Using a lambda function, expose a constructor taking a Python list as an input, to be converted to a std::vector
and invoking the actual constructor.
- Provide Python bindings for the addition (
__add__
), the read (__getitem__
) and write (__setitem__
) access, and the output stream (__str__
) operators.
- Package the Python module with the compiled C++ library using
setuptools
.
- Write a Python script to replicate the functionalities implemented in the
main.cpp
file.