Marko Rauhamaa <ma...@pacujo.net>:

> Important systems absolutely rely on the fact that the hashes can be
> used for identification. They are not just checksums. They are not
> double-checked with bit-to-bit comparisons of the actual data.

And in fact, you can use the principle in Python:

    class Thingy:
        def __init__(self, ...):
            ...
            self.stronghash = self.compute_strong_hash()
            self.hash = struct.unpack("Q", self.stronghash[:8])[0]

        def __hash__(self):
            return self.hash

        def __eq__(self, other):
            try:
                return self.stronghash == other.stronghash
            except AttributeError:
                return False


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to