New submission from Gawain Bolton <gp.bol...@computer.org>: Converting integer & long types to their ASCII representation is a task which can be quite CPU intensive due to the division & modulo operations. For long integers having hundreds or thousands of digits, this can take a truly significant amount of CPU time.
I have written a special case for base 10 conversions which allows for two improvements. 1) Two digits can be converted at a time, thus reducing the number of div/mod operations by two. 2) An optimizing compiler can avoid performing a division operation when the divisor is hardcoded. The expensive division operation can be replaced by a much faster multiplication operation. My tests show an improvement of 1.6x to 1.8x improvement for integer types and 2x improvement for longs. Note that because integers are displayed using fprintf(), the performance improvement is only seen when __repr__() is called. Patch is provided against trunk. It is somewhat difficult to read the patch in one or two places due to the use of tabs. ---------- components: Interpreter Core files: base10_conversion_performance_patch.txt messages: 91636 nosy: gawain severity: normal status: open title: Integer & Long types: Performance improvement of 1.6x to 2x for base 10 conversions type: performance versions: Python 2.7 Added file: http://bugs.python.org/file14736/base10_conversion_performance_patch.txt _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6713> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com