Author gawain
Recipients gawain
Date 2009-08-16.17:45:42
SpamBayes Score 9.42254e-09
Marked as misclassified No
Message-id <1250444749.02.0.599405992694.issue6713@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-08-16 17:45:49gawainsetrecipients: + gawain
2009-08-16 17:45:49gawainsetmessageid: <1250444749.02.0.599405992694.issue6713@psf.upfronthosting.co.za>
2009-08-16 17:45:44gawainlinkissue6713 messages
2009-08-16 17:45:44gawaincreate