Python Capsules are useful for passing C pointers between different Python modules. In particular, one can encapsulate a C function pointer in one module and unpack and call it in another module.
To begin, suppose we have two Boost.Python modules:
- Bird, which has methods setQuack() and callQuack().
- CppDuck, which has a method getQuack().
Our goal will be to get a function pointer with CppDuck.getQuack(), set it in another module in Bird.setQuack(), and finally call it with Bird.callQuack().