Message173185
| Author |
christian.heimes |
| Recipients |
Arfrever, PaulMcMillan, Vlado.Boza, benjamin.peterson, christian.heimes, dmalcolm, koniiiik, vstinner |
| Date |
2012年10月17日.16:53:31 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1350492811.58.0.0601543791813.issue14621@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|