def transform_eq(transformer, rhs):
    """
    Return an object that can be compared to another object after transforming
    that other object.

    The returned object will keep a log of equality checks done to it, and when
    formatted as a string (with ``repr``), will show the history of transformed
    objects and the ``rhs``.

    :param transformer: a function that takes the compared objects and returns
        a transformed version
    :param rhs: the actual data that should be compared with the result of
        transforming the compared object
    """
    class TransformedEq(object):
        def __init__(self):
            self.comparisons = []

        def __eq__(self, other):
            transformed = transformer(other)
            self.comparisons.append(transformed)
            return transformed == rhs

        def __ne__(self, other):
            return not self == other

        def __repr__(self):
            return "<TransformedEq comparisons=%r, operand=%r>" % (
                self.comparisons, rhs)

    return TransformedEq()