STINNER Victor added the comment:
fast_hash_3.patch is a litte bit (6%) slower for Unicode string shorter than 10
characters, but much faster for string equal or longer than 100 characters (up
to 10x faster).
I used the str type and disabled its cache ("_PyUnicode_HASH(self) = x;" in
unicode_hash()) to run my benchmark.
Summary | original | patched
---------------+------------+---------------
Length 1 | 231 ns (*) | 244 ns (+6%)
Length 3 | 238 ns (*) | 253 ns (+6%)
Length 10 | 254 ns (*) | 251 ns
Length 20 | 280 ns (*) | 256 ns (-8%)
Length 100 | 528 ns (*) | 321 ns (-39%)
Length 10 ** 4 | 32 us (*) | 9.49 us (-70%)
Length 10 ** 8 | 329 ms (*) | 104 ms (-68%)
---------------+------------+---------------
Total | 329 ms (*) | 104 ms (-68%)
----------
Added file: http://bugs.python.org/file29742/bench_hash.txt
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16427>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com