I have heard about different ways to call C functions from Python code, such as ctypes, cython, swig, Boost.python, etc. Each has pros and cons, of course. My question is about efficiency. I need to call C numerical functions from Python. A typical example of such a C function is:
double f(double x){
return sin(x)+cos(x)-pow(2,x) + x*x;
}
The invocation needs to be iterated 2000-200000 times in one run.
Under such context, which C->Python transformer should I use?
faccept a range of doubles might help, likevoid f(int num, double* vals);. Computing this for a single double at a time is unlikely to help much at all. And as Olaf pointed out, this is best done after you have a measured problem.