[issue11303] b'x'.decode('latin1') is much slower than b'x'.decode('latin-1')

STINNER Victor report at bugs.python.org
Thu Feb 24 17:35:46 CET 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Ooops, I attached the wrong patch. Here is the new fixed patch.

Without the patch:

>>> import timeit
>>> timeit.Timer("'a'.encode('latin1')").timeit()
3.8540711402893066
>>> timeit.Timer("'a'.encode('latin-1')").timeit()
1.4946870803833008

With the patch:

>>> import timeit
>>> timeit.Timer("'a'.encode('latin1')").timeit()
1.4461820125579834
>>> timeit.Timer("'a'.encode('latin-1')").timeit()
1.463456153869629

>>> timeit.Timer("'a'.encode('UTF-8')").timeit()
0.9479248523712158
>>> timeit.Timer("'a'.encode('UTF8')").timeit()
0.9208409786224365

----------
Added file: http://bugs.python.org/file20876/aggressive_normalization.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11303>
_______________________________________


More information about the Python-bugs-list mailing list