Showing content from http://mail.python.org/pipermail/python-dev/attachments/20111229/df516875/attachment.patch below:
diff -r f1298f4ec638 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Wed Dec 28 14:59:40 2011 +0000 +++ b/Objects/unicodeobject.c Thu Dec 29 11:11:09 2011 +0000 @@ -41,6 +41,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "ucnhash.h" +#include /* for seeding of hash value */ #ifdef MS_WINDOWS #include @@ -184,6 +185,9 @@ /* Single character Unicode strings in the Latin-1 range are being shared as well. */ static PyObject *unicode_latin1[256]; + +/* Base hash value (hash of empty string) */ +static Py_uhash_t base_hash; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -11107,7 +11111,7 @@ /* The hash function as a macro, gets expanded three times below. */ #define HASH(P) \ - x = (Py_uhash_t)*P << 7; \ + x = base_hash + (Py_uhash_t)*P << 7; \ while (--len >= 0) \ x = (1000003*x) ^ (Py_uhash_t)*P++; @@ -13869,6 +13873,14 @@ int _PyUnicode_Init(void) { int i; + time_t now; + + time(&now); + base_hash = (Py_uhash_t)now; + /* Avoid overly large numbers to reduce the chance of small strings + * hashing to -1 */ + if (base_hash == (Py_uhash_t)-1) + base_hash = (Py_uhash_t)-2; /* XXX - move this array to unicodectype.c ? */ Py_UCS2 linebreak[] = {
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4