Message156870
The proposed patch accelerates ascii decoding in a particular case, when the alignment of the input data coincides with the alignment of data in PyASCIIObject. This is a common case on 32-bit platforms. I did not check whether the patch have any effect on 64-bit platforms.
Without patch:
$ ./python -m timeit -n 1000 -s 'enc = "ascii"; import codecs; d = codecs.getdecoder(enc); x = ("\u0020" * 1000000).encode(enc)' 'd(x)'
1000 loops, best of 3: 1.93 msec per loop
$ ./python -m timeit -n 10000 -s 'enc = "ascii"; import codecs; d = codecs.getdecoder(enc); x = ("\u0020" * 100000).encode(enc)' 'd(x)'
10000 loops, best of 3: 59.4 usec per loop
With patch:
$ ./python -m timeit -n 1000 -s 'enc = "ascii"; import codecs; d = codecs.getdecoder(enc); x = ("\u0020" * 1000000).encode(enc)' 'd(x)'
1000 loops, best of 3: 1.46 msec per loop
$ ./python -m timeit -n 10000 -s 'enc = "ascii"; import codecs; d = codecs.getdecoder(enc); x = ("\u0020" * 100000).encode(enc)' 'd(x)'
10000 loops, best of 3: 35.6 usec per loop |
|
Date |
User |
Action |
Args |
2012-03-26 20:56:18 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
2012-03-26 20:56:18 | serhiy.storchaka | set | messageid: <1332795378.48.0.327832712874.issue14419@psf.upfronthosting.co.za> |
2012-03-26 20:56:17 | serhiy.storchaka | link | issue14419 messages |
2012-03-26 20:56:17 | serhiy.storchaka | create | |
|