StringFunction objects are as efficient as similar hardcoded
objects, i.e.,
class F: def __call__(self, x, y): return sin(x)*cos(y)but there is some overhead associated with the __call__ op. | |
Trick: extract the underlying method and call it directly
f1 = F() f2 = f1.__call__ # f2(x,y) is faster than f1(x,y)Can typically reduce CPU time from 1.3 to 1.0 | |
Conclusion: now we can grab formulas from command-line, GUI, Web, overhead} |