On Wed, Mar 14, 2012 at 12:08 AM, Laurent <moky.m...@gmail.com> wrote: > My question in the following : is it normal that the second one is *much* > slower than the first one ?
The reason why the second one is much faster is Sage has something called "fast_callable" which can optimize the evaluation of the function over say real numbers. For example, here is your f, and its fast_callable version: sage: a = RDF(2.3) sage: %timeit f(a) 5 loops, best of 3: 235 ms per loop sage: fc = fast_callable(f, vars=(x,), domain=RDF) sage: %timeit fc(a) 625 loops, best of 3: 53.1 µs per loop When you add a level of indirection, Sage doesn't (can't) know how to make such optimizations. --Mike -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org