Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(21)

Side by Side Diff: Objects/object.c

Issue 13704: Random number generator in Python core
Patch Set: Created 8 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* Generic object operations; and implementation of None */ 2 /* Generic object operations; and implementation of None */
3 3
4 #include "Python.h" 4 #include "Python.h"
5 #include "frameobject.h" 5 #include "frameobject.h"
6 6
7 #ifdef __cplusplus 7 #ifdef __cplusplus
8 extern "C" { 8 extern "C" {
9 #endif 9 #endif
10 10
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 x = -2; 752 x = -2;
753 return x; 753 return x;
754 } 754 }
755 755
756 Py_hash_t 756 Py_hash_t
757 _Py_HashBytes(unsigned char *p, Py_ssize_t len) 757 _Py_HashBytes(unsigned char *p, Py_ssize_t len)
758 { 758 {
759 Py_uhash_t x; 759 Py_uhash_t x;
760 Py_ssize_t i; 760 Py_ssize_t i;
761 761
762 x = (Py_uhash_t) *p << 7; 762 x = Py_RndHashSeed + ((Py_uhash_t) *p << 7);
gregory.p.smith 2012/01/15 02:18:38 Use ^ instead of +.
763 for (i = 0; i < len; i++) 763 for (i = 0; i < len; i++)
764 x = (1000003U * x) ^ (Py_uhash_t) *p++; 764 x = (1000003U * x) ^ (Py_uhash_t) *p++;
765 x ^= (Py_uhash_t) len; 765 x ^= (Py_uhash_t) len;
766 if (x == -1) 766 if (x == -1)
767 x = -2; 767 x = -2;
768 return x; 768 return x;
769 } 769 }
770 770
771 Py_hash_t 771 Py_hash_t
772 PyObject_HashNotImplemented(PyObject *v) 772 PyObject_HashNotImplemented(PyObject *v)
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 _Py_Dealloc(PyObject *op) 1922 _Py_Dealloc(PyObject *op)
1923 { 1923 {
1924 _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA 1924 _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA
1925 (*Py_TYPE(op)->tp_dealloc)(op); 1925 (*Py_TYPE(op)->tp_dealloc)(op);
1926 } 1926 }
1927 #endif 1927 #endif
1928 1928
1929 #ifdef __cplusplus 1929 #ifdef __cplusplus
1930 } 1930 }
1931 #endif 1931 #endif
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+