Package: pari-stable
Version: all
Severity: wishlist

When gp encounters decimal numbers (in strings, at least, with read or eval) it converts them to the native format using what appears to be a quadratic algorithm:

> s=Str(10^10^6);
time = 125 ms.
> eval(s);
time = 1,892 ms.
> s=Str(10^10^7);
  *** Str: Warning: increasing stack size to 40000000.
  *** Str: Warning: increasing stack size to 80000000.
time = 2,109 ms.
> eval(s);
  *** eval: Warning: increasing stack size to 40000000.
time = 4min, 30,219 ms.
> log((4*60+30.219)/1.892)/log(10)
%1 = 2.1547947503887454560124003527679024030

It looks like GMP does this pretty well; anecdotally around 100 time faster for large numbers. This may be as easy as hooking into gmp_sscanf at some point if GMP is used.

https://gmplib.org/manual/Formatted-Input-Functions.html
https://gmplib.org/manual/Radix-to-Binary.html

Charles Greathouse
Case Western Reserve University