[issue14700] Integer overflow in classic string formatting

Serhiy Storchaka report at bugs.python.org
Mon May 7 14:14:16 CEST 2012

Serhiy Storchaka <storchaka at gmail.com> added the comment:

Mark, I deliberately have not used the exact formula for the overflow. Comparison with the constant is much cheaper than division or multiplication.


./python -m timeit -s 'f="%.1234567890s"*100;x=("",)*100'  'f%x'

Before changeset 064c2d0483f8:  10000 loops, best of 3: 27.1 usec per loop
Changeset 064c2d0483f8:  10000 loops, best of 3: 25.7 usec per loop
Original patch:  100000 loops, best of 3: 18.2 usec per loop


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list