Hi!

If you go through the code of PermutationGroup_generic.__cmp__, you
see that the comparison is done via the gap interface. It turns out
that the use of the gap interface requires a huge amount of regular
expressions:

sage: g1=gap('SymmetricGroup([1 .. 5])')
sage: g2=gap('SymmetricGroup([1 .. 5])')
sage: prun gap.eval(g1.name() + gap._equality_symbol() + g2.name())
   ncalls  tottime  percall  cumtime  percall filename:lineno
(function)
        8    0.000    0.000    0.001    0.000 pexpect.py:815
(compile_pattern_list)
        8    0.000    0.000    0.001    0.000 pexpect.py:914
(expect_list)
       83    0.000    0.000    0.001    0.000 re.py:227(_compile)
       83    0.000    0.000    0.001    0.000 re.py:186(compile)

Now, in your second function, these 8 pexpect calls and 83 regular
expressions (for a single comparison!!) sum up to the bad timings that
you found.

I don't know how to overcome this bottle neck.
The problem is:
 1) If one decides to compare permutation groups by comparing their
list of elements (which is faster in your examples) then sooner or
later one will have problems with big group orders
 2) If one decides to compare the group via the gap interface then
apparently one has trouble with all the regular expressions.
 3) Or one may try and improve the pexpect interfaces.

A partial solution for 3) might be to pre-compile certain useful
regular expressions, and store them as an attribute of the interface
instance. In that way, it would not be needed to do the 83
compilations of regular expressions over and over again.

Probably other people can tell whether this suggestion makes sense. At
least, when I worked at InfinitePolynomialRing, a similar trick
improved the performance a lot!

Cheers,
    Simon

--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to