1.1 --- a/lib/__builtins__/str.py Fri Dec 02 00:54:32 2016 +0100
1.2 +++ b/lib/__builtins__/str.py Fri Dec 02 00:55:45 2016 +0100
1.3 @@ -27,6 +27,9 @@
1.4
1.5 "The base class for all strings."
1.6
1.7 + _p = 0x03ffffff
1.8 + _a = 31
1.9 +
1.10 def __init__(self):
1.11
1.12 "Initialise the string."
1.13 @@ -37,6 +40,20 @@
1.14
1.15 self.__data__ = None
1.16
1.17 + def __hash__(self):
1.18 +
1.19 + "Return a value for hashing purposes."
1.20 +
1.21 + result = 0
1.22 + l = self.__len__()
1.23 + i = 0
1.24 +
1.25 + while i < l:
1.26 + result = (result * self._a + ord(self.__get_single_item__(i))) % self._p
1.27 + i += 1
1.28 +
1.29 + return result
1.30 +
1.31 def __iadd__(self, other):
1.32
1.33 "Return a new string for the operation."