Helloooooooooo everybody !
In the brand new design code that Volker is merging into Sage these days [1], one of the functions calls two_squares very often. two_squares tells you if an integer can be written as the sum of two squares, and because it calls GAP this functions is a bit too slow, and it is actually the bottleneck in some of the computations...
Do you know if :
1) There would be a way to make it quicker to communicate with GAP, as we call it often
2) There is another implementation of two_squares in some other library we ship that we could use instead
3) It can be re-written easily with pure Sage tools ?
Thanks for your help ! :-)
Aaaaaaaaaaaaaaand I hope we will eventually hear some praise for Sage because of its designs code... It is quite cool already :-P
Nathann
[1] sorry for the conflicts Volker, I really try to make it as clean as I can and to fix them quickly, but almost-linearly-ordered tickets is hell to manage :-/
sage: 4367424234**2+325235235**2
19180172397815991981
sage: %prun two_squares(19180172397815991981)
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
2 0.001 0.000 0.001 0.000 {posix.write}
6 0.000 0.000 0.001 0.000 pexpect.py:918(expect_list)
112 0.000 0.000 0.000 0.000 {method 'search' of '_sre.SRE_Pattern' objects}
1 0.000 0.000 0.001 0.001 gap.py:576(_execute_line)
1 0.000 0.000 0.000 0.000 {eval}
1 0.000 0.000 0.001 0.001 arith.py:4910(two_squares)
1 0.000 0.000 0.001 0.001 expect.py:1154(eval)
37 0.000 0.000 0.000 0.000 {method 'start' of '_sre.SRE_Match' objects}
1 0.000 0.000 0.001 0.001 gap.py:510(eval)
1 0.000 0.000 0.001 0.001 gap.py:664(_eval_line)
1 0.000 0.000 0.000 0.000 pexpect.py:502(read_nonblocking)
....