This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gawain
Recipients gawain
Date 2009-08-16.17:45:42
SpamBayes Score 9.42254e-09
Marked as misclassified No
Message-id <>
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.
Date User Action Args
2009-08-16 17:45:49gawainsetrecipients: + gawain
2009-08-16 17:45:49gawainsetmessageid: <>
2009-08-16 17:45:44gawainlinkissue6713 messages
2009-08-16 17:45:44gawaincreate