New submission from Serhiy Storchaka:
In the discussion of issue14621 it was noted that much more complex hash
algorithms can overtake the current one due to the fact that they process more
data at a time. Here is a patch that implements this idea for the current
algorithm. Also code duplication removed.
Microbenchmarks:
$ ./python -m timeit -n 1 -s "t = b'a' * 10**8" "hash(t)"
$ ./python -m timeit -n 1 -s "t = 'a' * 10**8" "hash(t)"
$ ./python -m timeit -n 1 -s "t = '\u0100' * 10**8" "hash(t)"
$ ./python -m timeit -n 1 -s "t = '\U00010000' * 10**8" "hash(t)"
Results on 32-bit Linux on AMD Athlon 64 X2 4600+:
original patched speedup
bytes 181 msec 45.7 msec 4x
UCS1 429 msec 45.7 msec 9.4x
UCS2 179 msec 92 msec 1.9x
UCS4 183 msec 183 msec 1x
If the idea is acceptable, I will create benchmarks for short strings.
----------
components: Interpreter Core
files: fast_hash.patch
keywords: patch
messages: 175093
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Faster hash implementation
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file27920/fast_hash.patch
_______________________________________
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