def delta(self, mapping, prefix):
        """
        return a delta containing values that have changed.
        """
        previous = self.getrange(prefix, strip=True)
        if not previous:
            pk = set()
        else:
            pk = set(previous.keys())
        ck = set(mapping.keys())
        delta = DeltaSet()

        # added
        for k in ck.difference(pk):
            delta[k] = Delta(None, mapping[k])

        # removed
        for k in pk.difference(ck):
            delta[k] = Delta(previous[k], None)

        # changed
        for k in pk.intersection(ck):
            c = mapping[k]
            p = previous[k]
            if c != p:
                delta[k] = Delta(p, c)

        return delta
def delta ( self , mapping , prefix ) : previous = self . getrange ( prefix , strip = True ) if not previous : pk = set ( ) else : pk = set ( previous . keys ( ) ) ck = set ( mapping . keys ( ) ) delta = DeltaSet ( ) for k in ck . difference ( pk ) : delta [ k ] = Delta ( None , mapping [ k ] ) for k in pk . difference ( ck ) : delta [ k ] = Delta ( previous [ k ] , None ) for k in pk . intersection ( ck ) : c = mapping [ k ] p = previous [ k ] if c != p : delta [ k ] = Delta ( p , c ) return delta
return a delta containing values that have changed.