Josh Rosenberg added the comment:

On:  if (... a+b will not overflow ...) { 

Since you limited the optimization for addition to single digit numbers, at 
least for addition and subtraction, overflow is impossible. The signed twodigit 
you use for the result is guaranteed to be able to store far larger numbers 
than addition of single digits can produce. In fact, due to the extra wasted 
bit on large (30 bit) digits, if you used a fixed width 32 bit type for 
addition/subtraction, and a fixed width 64 bit type for multiplication, 
overflow would be impossible regardless of whether you used 15 or 30 bit digits.

On a related note: Presumably you should check if the abs(size) <= 1 like in 
longobject.c, not == 1, or you omit the fast path for 0. Doesn't come up much, 
not worth paying extra to optimize, but it costs nothing to handle it.

----------
nosy: +josh.rosenberg

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21955>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to