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 serhiy.storchaka
Recipients benjamin.peterson, pitrou, serhiy.storchaka, skrah, vstinner
Date 2012-03-20.16:53:24
SpamBayes Score 0.0004749617
Marked as misclassified No
Message-id <1332262405.46.0.993079913895.issue14249@psf.upfronthosting.co.za>
In-reply-to
Content
"(unsigned short)(long >> 32)" returns the 16 bits (32..48) if short is 16-bit. I agree that this variant is more strict and reliable (and this was my original version) and if you do not find it verbose and redundant, so be it. The difference will be noticeable only on a very exotic platform (with a 9-bit chars, for example), where the original code also will not work. Frankly, in this straightforward patch hacking is less than in the original code.

I made a mistake with the microbenchmark. In fact, acceleration is not 5%, but 20-40%.

./python -m timeit -s 'import codecs; d = codecs.utf_16_be_decode; x = (" " * 1000).encode("utf-16be")' 'd(x)'
./python -m timeit -s 'import codecs; d = codecs.utf_16_be_decode; x = ("\u263A" * 1000).encode("utf-16be")' 'd(x)'
History
Date User Action Args
2012-03-20 16:53:25serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner, benjamin.peterson, skrah
2012-03-20 16:53:25serhiy.storchakasetmessageid: <1332262405.46.0.993079913895.issue14249@psf.upfronthosting.co.za>
2012-03-20 16:53:24serhiy.storchakalinkissue14249 messages
2012-03-20 16:53:24serhiy.storchakacreate