On Aug 23, 8:15 pm, William Stein <wst...@gmail.com> wrote: > On sage.math (Linux) I get the same timing as you:
That's good, because that's where I did it. A sage with the ecl library interface is available in "/scratch/nbruin/ sage-4.1.1-ecl-x86_64-Linux" so if you want to do timings for yourself, you can. The slowing down has nothing to do with the sage interface, but probably with the macro #$...$ sage: timeit("libadd(1,2)") 625 loops, best of 3: 157 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 197 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 265 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 347 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 450 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 611 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 840 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 995 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 1.23 ms per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 1.42 ms per loop sage: timeit("libadd(1,2)") 125 loops, best of 3: 1.54 ms per loop If we take maxima's parser completely out of the picture: sage: def libadd(a,b): ....: return ecl_eval("(meval* '((mplus) %s %s))"%(1,2)) ....: sage: timeit("libadd(1,2)") 625 loops, best of 3: 14.5 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 14.4 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 13.9 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 14.9 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 14.9 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 15.1 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 15.1 µs per loop sage: timeit("libadd(1,2)") 625 loops, best of 3: 14.9 µs per loop we see a much more respectable time, and more importantly, no systematic increase. There is still a "string_to_object" involved here. We could also do: sage: L=string_to_object("(meval* '((mplus) %s %s))"%(1,2)) sage: L <ECL: (MEVAL* '((MPLUS) 1 2)) > sage: timeit("L.eval()") 625 loops, best of 3: 3.42 µs per loop sage: timeit("L.eval()") 625 loops, best of 3: 3.41 µs per loop sage: timeit("L.eval()") 625 loops, best of 3: 3.42 µs per loop sage: timeit("L.eval()") 625 loops, best of 3: 3.47 µs per loop which takes all communication out of the picture. It's just maxima simplifying the expression to 3. ECL has a good C-level interface to construct and take apart lisp S-expressions, so ultimately we would not be talking to maxima's parser at all. I just haven't interfaced those routines yet. I think it does shows that there are considerable gains to be had. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---