[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

Mark Dickinson report at bugs.python.org
Mon Feb 16 17:48:38 CET 2009


Mark Dickinson <dickinsm at gmail.com> added the comment:

Updated patch against py3k.  I'm interested in getting this into the trunk 
as well, but py3k is more important (because *all* integers are long 
integers).  It's also a little more complicated to do this for py3k 
(mostly because of all the small integer caching), so backporting to
2.7 is easier than trying to forward port a patch from 2.7 to 3.1.

Notes:

- I've added a configure option --enable-big-digits (there are probably 
better names), enabled by default.  So you can use --disable-big-digits
to get the old 15-bit behaviour.

- I *think* this patch should work on Windows; confirmation would be 
appreciated.

- I've removed the fast multiplication code, in the interests of keeping 
the patch simple.  If this patch goes in, we can concentrate on speeding 
up multiplication afterwards.  For now, note that 30-bit digits give
the *potential* for significant speedups in multiplication and division 
(see next item).

- There's a nasty 'feature' in x_divmod: the multiplication in the 
innermost loop is digit-by-twodigits -> twodigits, when it should be 
digit-by-digit -> twodigits;  this probably causes significant slowdown 
with 30-bit digits.  This may explain Antoine's outlier.
Again, if this patch goes in I'll work on fixing x_divmod.

- Re: Victor's comment about a 'base' attribute:  I tried this, but
quickly discovered that we still need the 'bits_per_digit' for tests.
I think that binaryness is so ingrained that it's not really worth
worrying about the possibility of the base changing from a power of 2 to a 
power of 10.  So in the end I left base out.

- It did occur to me that NSMALLPOSINTS and NSMALLNEGINTS might usefully 
be exposed in sys.int_info, mostly for the purposes of testing.  Thoughts?

----------
priority:  -> high
stage:  -> patch review
versions: +Python 2.7
Added file: http://bugs.python.org/file13108/30bit_longdigit13.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4258>
_______________________________________


More information about the Python-bugs-list mailing list