Serhiy Storchaka <storch...@gmail.com> added the comment:

"(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)'

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14249>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to