On Fri, Oct 17, 2008 at 4:18 PM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: > Mmm, I'm not sure if you got the idea. In your code, I'm talking about > removing 'func2', and passing to 'cuadrature' an instance of MyFunc > (and implement __call__ in MyFunc), like this > > cdef class MyFunc: > cdef double (*f)(double) > def __call__(self, a): > return array([self.f(x) for x in a]) > > myfunc = MyFunc() > myfunc.set_f(f) > val, err = quadrature(myfunc, a, b) > > See the attached files for a working example. Just run test_functor.py > (uses pyximport, no need to build yourself functor.pyx -> functor.so) > to make sure all is is working, then look at the fine code ;-).
Ah, now it looks much better. So why not to combine your code with Dag's code to make vectorize really fast? :) Then there should be basically now overhead if you pass it long numpy arrays. Thanks for the tips and especially about pyximport! I didn't know about it, it's just awesome. I hated fiddling with makefiles all the time I did some cython development. Together with pure python mode, this will be just awesome. I am very excited about all of these tools, they make life so much easier. Wow, this brings a lot of new possibilities, like trying to compile the module first and if it fails, just import it as a python one (assuming pure python syntax) and in any case you get the job done. Ondrej _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
