C2PY_IGNORE
The C2PY_IGNORE annotation can be used to exclude specific functions or classes from being exposed in the Python bindings.
C++ code
// c2py_ignore.cpp
#include "c2py/c2py.hpp"
// Some function we don't want to wrap.
C2PY_IGNORE int f(int x) { return x * 2; }
// Another function we want to wrap.
int g(int y) { return y * 3; }
Usage in Python
After generating the extension module, we can use it in Python:
>>> from c2py_ignore import *
>>> g(2)
6
>>> f(2)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
f(2)
^
NameError: name 'f' is not defined
As expected, only the function g is available in Python, while f has been ignored.