Cython has “first class function objects” - how efficient are they? Do they have Python overhead?
问题 I have an external library that computes the optima, say minima, of a given function. Say its headers give me a function double[] minimizer(ObjFun f) where the headers define typedef double (*ObjFun)(double x[]) I have generated Cython wrappers for this library. I now want to give user parameterized functions to it, specifically, I want to write a function def getFunction(double q11, double q12, double q22): cdef f(double x[]): return x[0]*x[0]*q11 + 2*x[0]*x[1]*q12 + x[1]*x[1]*q22 return f