Reputation: 2157
What is the fastest way to call C/C++ functions and use C++ classes? There are various methods to do this such as Python Extension Module (Python.h), Cython, SWIG, Boost, and etc.
I've already implement C/C++ functions and C++ classes. Because performance is very important in my project.
So, I want to call C/C++ functions and use C++ classes in python with minimal modification of c/c++ code (or wrapping with no change of existing code). What is the best way?
Upvotes: 0
Views: 506
Reputation: 31
If you already have the functions in C++, I suggest you create a dll or more and check how they can be called from python. As far as I know there is a library in python for things like this named ctypes and it works like this:
int sum(int a, int b)
{
return a + b;
}
import ctypes
a = ctypes.WinDLL ("path\\to\\mydll.dll")
result = a.sum(10,1)
print(result)
Upvotes: 2