]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Issues #26289 and #26315: Optimize floor/modulo div for single-digit longs
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 11 Feb 2016 15:26:27 +0000 (10:26 -0500)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 11 Feb 2016 15:26:27 +0000 (10:26 -0500)
commite0b23095ee03a11d09f38cbc689307dc5c93afda
tree4854be21dd4b87937cf03583bd599c1f8d3ddebd
parent2da89d70fcad24cc266f6919aadd40c0838c4c5f
Issues #26289 and #26315: Optimize floor/modulo div for single-digit longs

Microbenchmarks show 2-2.5x improvement.  Built-in 'divmod' function
is now also ~10% faster.

-m timeit -s "x=22331" "x//2;x//-3;x//4;x//5;x//-6;x//7;x//8;x//-99;x//100;"
with patch: 0.321          without patch: 0.633

-m timeit -s "x=22331" "x%2;x%3;x%-4;x%5;x%6;x%-7;x%8;x%99;x%-100;"
with patch: 0.224          without patch: 0.66

Big thanks to Serhiy Storchaka, Mark Dickinson and Victor Stinner for
thorow code reviews and algorithms improvements.
Lib/test/test_long.py
Misc/NEWS
Objects/longobject.c