Alternative to python hash function for arbitrary objects
问题 In python2.7, I'm successfully using hash() to place objects into buckets stored persistently on disk. A mockup code looks like this: class PersistentDict(object): def __setitem__(self, key, value): bucket_index = (hash(key)&0xffffffff) % self.bucket_count self._store_to_bucket(bucket_index, key, value) def __getitem__(self, key): bucket_index = (hash(key)&0xffffffff) % self.bucket_count return self._fetch_from_bucket(bucket_index)[key] In python3, hash() uses a random or fixed salt, which