Huge asymptotic speedup for base conversion
Huge asymptotic speedup for base conversion

Use a recursive algorithm based on repeatedly squaring the base for both
to_base_ten and from_base_ten.  The from_base_ten speedup is not as huge
as I hoped, because Python’s divmod is pathetically
slow (https://bugs.python.org/issue3451), but it at least it’s slow C
code rather than slow Python code.

Here are some benchmarks:

Old to_base_ten:
  lC*d    100000    2.6s
  lC*d    200000   10s
  lC*d    400000   42s

New to_base_ten:
  lC*d    100000    0.046s
  lC*d    200000    0.093s
  lC*d    400000    0.19s
  ⋮
  lC*d  12800000    7.5s
  lC*d  25600000   16s
  lC*d  51200000   39s

Old from_base_ten:
  lC^256   50000    4.9s
  lC^256  100000   19s
  lC^256  200000   76s

New from_base_ten:
  lC^256   50000    0.12s
  lC^256  100000    0.37s
  lC^256  200000    1.3s
  lC^256  400000    4.8s
  lC^256  800000   19s
  lC^256 1600000   76s

Signed-off-by: Anders Kaseorg <087231934ba8fcf78bc142ce37d193b895ac03c4@mit.edu>

isaacg1/pyth,isaacg1/pyth,jakobkogler/pyth,jakobkogler/pyth