#19585: Improve efficiency of calling GAP functions
-------------------------------------+-------------------------------------
       Reporter:  jaanos             |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.10
      Component:  interfaces         |   Resolution:
       Keywords:  GAP functions      |    Merged in:
  interface                          |    Reviewers:  Travis Scrimshaw
        Authors:  Janoš Vidali       |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  31a173bccd732cb8d8b656d6882dcec074a87b7d
  u/jaanos/improve_calling_gap_function-19585|     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------
Changes (by jaanos):

 * status:  needs_review => needs_work


Comment:

 Hello everybody!

 It turns out that we still have some issues here.

 Firstly, GAP function calls don't actually work when done through a
 temporary file, nor does getting a variable (which is essentially a
 `Print` call). The reason for this is that when `_eval_line_using_file` is
 called, it first looks for a `:=` token - if there is one, all is well;
 but since we are relying on `last`, we don't have one, and a `Print()` is
 wrapped around our function call. If the function actually returns a
 value, this gives an impression of working, since the correct result is
 printed - but we get an `AsciiArtString` instead of a `GapElement`. When
 the function does not return a value, the situation is even worse, since
 printing the result of a function which does not return a result results
 in an error (which is silently suppressed, and an empty string is
 returned).

 Now, it seems that we can't really solve this problem, since `last` is not
 updated when commands are read from a file. So I'd suggest this is how we
 deal with it:
 * If the command is short, evaluate it directly (one or two `eval`s, as in
 the latest commit).
 * If the command is long, we assign its result to a variable. This will of
 course cause an error if the function does not return a value - but such
 functions are few and it is much more likely that a (long) function does
 return a value.
 * When getting a variable, we make a direct call to
 `Expect._eval_line_using_file` if a file should be needed to avoid having
 two `Print`s and hence an error.

 This problem has existed before this ticket was opened, so the cases when
 a temporary file is used are marginal at best. If you think it is OK, I
 can implement the above solution (or maybe someone else can do it, since
 I'll probably be busy in the following days).

 Secondly, `get_using_file` is indeed meant to use a file to read the
 results. So the code regarding `_get_using_file` should probably be left
 as it is (of course we can always set `_get_using_file`, so we don't need
 `try`/`except` blocks to check it), although the length of the input may
 be a poor predictor of the length of the output. Now, we should check
 whether getting with a file is actually faster with GAP than directly
 reading the output.

 Janoš

--
Ticket URL: <http://trac.sagemath.org/ticket/19585#comment:28>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to