The use of PXD files is very similar to that of header files in C/C++. When writing bindings to any C/C++ code, it is a good practice to declare all C/C++ interfaces within a .pxd
file. This stands for Python External Declarations, at least it does in my mind. So, when we add blocks such as this:
cdef extern from "AddFunction.h": cdef int AddFunction(int, int)
We can instead put this directly into a bindings.pxd
file and import this at any time inside any .pyx
file:
cimport bindings
Notice the distinction between cimport
for the .pxd
files and a simple import for all normal Python imports.