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 mark.dickinson
Recipients mark.dickinson, pitrou, vstinner
Date 2009-03-21.22:19:27
SpamBayes Score 5.5551345e-07
Marked as misclassified No
Message-id <1237673974.24.0.190474700384.issue5512@psf.upfronthosting.co.za>
In-reply-to
Content
Updated patch.  Lots of cleanup, but only one significant change:  the 
inner loop now uses signed arithmetic instead of unsigned arithmetic.  This saves a negation and fixes a subtle bug: the previous inner loop code 
was incorrect when using 15-bit digits on machines with sizeof(short) == 
sizeof(long).  Not that I know of any such machines:  the Cray T3E 
famously has no 16-bit integer type, but there sizeof(short) is 4 and 
sizeof(long) is 8.

A few more timings, this time from doing a single huge integer division:  
10**1000000//10**500000 (so this effectively times just the inner loop, 
since all else will be insignificant).  All timings are best-of-5, from 
non-debug builds of py3k, on the same system: OS X 10.5.6/2.4 GHz Core 2 
Duo.  Times in brackets are the approximate per-inner-loop times 
(remembering that there are 4 times as many iterations of the inner loop 
for 15-bit digits).

32-bit build, 15-bit digits, unpatched:  92382.2 ms   (~7.5 ns)
32-bit build, 15-bit digits, patched:    36473.3 ms   (~3.0 ns)
64-bit build, 30-bit digits, unpatched:  14581.4 ms   (~4.8 ns)
64-bit build, 30-bit digits, patched:     7385.1 ms   (~2.4 ns)

... and just for fun, the other combinations:

64-bit build, 15-bit digits, unpatched:  61927.5 ms   (~5.1 ns)
64-bit build, 15-bit digits, patched:    43632.9 ms   (~3.6 ns)
32-bit build, 30-bit digits, unpatched:  62374.1 ms  (~20.3 ns)
32-bit build, 30-bit digits, patched:    26928.3 ms   (~8.8 ns)


Thanks for the updated pidigits script, Victor!  Maybe this is too small 
right now to be worth including in the Tools directory, but I hope we can 
fatten it up with some other benchmarks.  What do you think?
History
Date User Action Args
2009-03-21 22:19:34mark.dickinsonsetrecipients: + mark.dickinson, pitrou, vstinner
2009-03-21 22:19:34mark.dickinsonsetmessageid: <1237673974.24.0.190474700384.issue5512@psf.upfronthosting.co.za>
2009-03-21 22:19:31mark.dickinsonlinkissue5512 messages
2009-03-21 22:19:30mark.dickinsoncreate