Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting string into number does not work properly

Here is an example with huge integer number "n".

n=2^7000000;

Sage can convert huge integer number into string very quickly:

s=str(n);

But the other way, i.e. the same huge string converting back into integer number is very slow:

m=int(s);

It should be done in approximately same time as variables "m", "n", "s" are of the same length. I also tried to use eval(s) and sage_eval(s) instead of int(s) and all are very slow.

Mathematica can do all the above operation much more quickly than Sage.

Do you know, where the problem is? Is there some other function besides "int", "eval" and "sage_eval" that can do it faster?

click to hide/show revision 2
retagged

Converting string into number does not work properly

Here is an example with huge integer number "n".

n=2^7000000;

Sage can convert huge integer number into string very quickly:

s=str(n);

But the other way, i.e. the same huge string converting back into integer number is very slow:

m=int(s);

It should be done in approximately same time as variables "m", "n", "s" are of the same length. I also tried to use eval(s) and sage_eval(s) instead of int(s) and all are very slow.

Mathematica can do all the above operation much more quickly than Sage.

Do you know, where the problem is? Is there some other function besides "int", "eval" and "sage_eval" that can do it faster?