def hash__Complex(space, w_value): #this is straight out of CPython complex implementation hashreal = _hash_float(space, w_value.realval) if hashreal == -1: return space.newint(-1) hashimg = _hash_float(space, w_value.imagval) if hashimg == -1: return space.newint(-1) combined = hashreal + 1000003 * hashimg if (combined == -1): combined = -2 return space.newint(combined)
def descr_hash(self, space): mult = 1000003 x = 0x345678 z = typelen for i in iter_n: value = getattr(self, 'value%s' % i) if typetuple[i] == object: y = space.int_w(space.hash(value)) elif typetuple[i] == float: # get the correct hash for float which is an # integer & other less frequent cases from pypy.objspace.std.floatobject import _hash_float y = _hash_float(space, value) elif typetuple[i] == int: # hash for int which is different from the hash # given by rpython from pypy.objspace.std.intobject import _hash_int y = _hash_int(value) else: raise NotImplementedError x = (x ^ y) * mult z -= 1 mult += 82520 + z + z x += 97531 return space.newint(intmask(x))
def descr_hash(self, space): mult = 1000003 x = 0x345678 z = typelen for i in iter_n: value = getattr(self, 'value%s' % i) if typetuple[i] == object: y = space.int_w(space.hash(value)) elif typetuple[i] == int: # mimic cpythons behavior of a hash value of -2 for -1 y = value if y == -1: y = -2 elif typetuple[i] == float: # get the correct hash for float which is an # integer & other less frequent cases from pypy.objspace.std.floatobject import _hash_float y = _hash_float(space, value) else: y = compute_hash(value) x = (x ^ y) * mult z -= 1 mult += 82520 + z + z x += 97531 return space.newint(intmask(x))
def descr_hash(self, space): mult = 1000003 x = 0x345678 z = typelen for i in iter_n: value = getattr(self, 'value%s' % i) if typetuple[i] == object: y = space.int_w(space.hash(value)) elif typetuple[i] == int: # mimic cpythons behavior of a hash value of -2 for -1 y = value y -= (y == -1 ) # No explicit condition, to avoid JIT bridges elif typetuple[i] == float: # get the correct hash for float which is an # integer & other less frequent cases from pypy.objspace.std.floatobject import _hash_float y = _hash_float(space, value) y -= (y == -1) else: assert 0, "unreachable" x = (x ^ y) * mult z -= 1 mult += 82520 + z + z x += 97531 return space.newint(intmask(x))
def hash(self, space): # XXX duplicate logic from tupleobject.py mult = 1000003 x = 0x345678 z = nValues for i in iter_n: value = getattr(self, 'value%s' % i) if typetuple[i] == object: y = space.int_w(space.hash(value)) elif typetuple[i] == float: # get the correct hash for float which is an # integer & other less frequent cases from pypy.objspace.std.floatobject import _hash_float y = _hash_float(space, value) else: y = compute_hash(value) x = (x ^ y) * mult z -= 1 mult += 82520 + z + z x += 97531 return space.wrap(intmask(x))
def descr_hash(self, space): hashreal = _hash_float(space, self.realval) hashimg = _hash_float(space, self.imagval) # 0 if self.imagval == 0 h = intmask(hashreal + 1000003 * hashimg) h -= (h == -1) return space.newint(h)
def descr_hash(self, space): hashreal = _hash_float(space, self.realval) hashimg = _hash_float(space, self.imagval) combined = intmask(hashreal + 1000003 * hashimg) return space.newint(combined)
def descr_hash(self, space): hashreal = _hash_float(space, self.realval) hashimg = _hash_float(space, self.imagval) combined = intmask(hashreal + HASH_IMAG * hashimg) return space.newint(-2 if combined == -1 else combined)
def hash__Complex(space, w_value): hashreal = _hash_float(space, w_value.realval) hashimg = _hash_float(space, w_value.imagval) combined = hashreal + 1000003 * hashimg return space.newint(combined)