On 8/23/09, William Stein <wst...@gmail.com> wrote: > In fact, I am mildly surprised that the above two timings between ecl > and maxima are so different. I wonder why it is an order of magnitude > faster to compute "(+ 1 2)" than to compute "(MEVAL #$ 1 + 2$)". > Perhaps in the second case the Maxima parser has to parse "1+2"?
Well, the Maxima parser is slow, but also (MEVAL '((MPLUS) 1 2)) goes through the simplifier, which eventually calls (+ 1 2) as a special case. The simplifier attempts to apply various identities, so it's really much more complex than just adding two integers. I suppose that adding numbers is an important enough special case that some effort could be spent trying to speed it up. But most of the fun is in symbolic stuff, so that's probably why it hasn't been done yet. Not sure in this case whether the parser or simplifier dominates. > Robert Dodier -- do you have any crazy ideas why Maxima might get > slower to do the same thing over time? Is it caching all output > somewhere? What other caching might be going on? This kind of stuff drives me nuts ... It appears the problem is that Maxima is keeping a list of all input streams that have ever been opened, and traversing the list every time an input line is parsed. I'm guessing that Sage creates a little input file each time it calls Maxima or something like that which creates a new input stream every time. (In that case a work-around is to avoid creating so many new input streams. Maybe open a socket and send stuff through that?) That is in the code which annotates input with debugging info. Try this: either edit maxima/src/nparse.lisp and clobber the existing definition of ADD-LINEINFO with: (defun add-lineinfo (x) x) or, somehow define ADD-LINEINFO in a running Maxima session. I would try this: :lisp (defun add-lineinfo (x) x) but istr you had trouble with that, so how about ?add\-lineinfo (x) := x; translate (?add\-lineinfo); That's a long shot -- define a Maxima function by the same name first, then tell Maxima to translate it to Lisp. Worth a try. FWIW & HTH Robert Dodier --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---