Message173185
I've modified unicodeobject's unicode_hash() function. V8's algorithm is about 55% slower for a 800 MB ASCII string on my box.
Python's current hash algorithm for bytes and unicode:
while (--len >= 0)
x = (_PyHASH_MULTIPLIER * x) ^ (Py_uhash_t) *P++;
$ ./python -m timeit -s "t = 'abcdefgh' * int(1E8)" "hash(t)"
10 loops, best of 3: 94.1 msec per loop
V8's algorithm:
while (--len >= 0) {
x += (Py_uhash_t) *P++;
x += ((x + (Py_uhash_t)len) << 10);
x ^= (x >> 6);
}
$ ./python -m timeit -s "t = 'abcdefgh' * int(1E8)" "hash(t)"
10 loops, best of 3: 164 msec per loop |
|
Date |
User |
Action |
Args |
2012-10-17 16:53:31 | christian.heimes | set | recipients:
+ christian.heimes, vstinner, benjamin.peterson, Arfrever, dmalcolm, PaulMcMillan, Vlado.Boza, koniiiik |
2012-10-17 16:53:31 | christian.heimes | set | messageid: <1350492811.58.0.0601543791813.issue14621@psf.upfronthosting.co.za> |
2012-10-17 16:53:31 | christian.heimes | link | issue14621 messages |
2012-10-17 16:53:31 | christian.heimes | create | |
|