![]() | Weave is an easy-to-use tool for inlining C++ snippets in Python codes |
![]() | A quick demo shows its potential
class Grid2Deff: ... def ext_gridloop1_weave(self, fstr): """Migrate loop to C++ with aid of Weave.""" from scipy import weave # the callback function is now coded in C++ # (fstr must be valid C++ code): extra_code = r""" double cppcb(double x, double y) { return %s; } """ % fstr |