[issue14249] unicodeobject.c: aliasing warnings

Serhiy Storchaka report at bugs.python.org
Tue Mar 20 17:53:25 CET 2012


Serhiy Storchaka <storchaka at 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 <report at bugs.python.org>
<http://bugs.python.org/issue14249>
_______________________________________


More information about the Python-bugs-list mailing list