def get_diff(left, right):
    """Get the difference of both lists.

    The result will be a dict with this form {'+': [], '-': []}.
    Items listed in '+' exist only in the right list,
    items listed in '-' exist only in the left list.

    """
    res = {'+': [], '-': []}

    def partition(objects):
        """Partition the passed object list."""
        res = {}
        for o in objects:
            t = type(o)
            if type(o) not in res:
                res[t] = []
            res[t].append(o)
        return res

    def get_not_included(foo, bar):
        """Compare objects from foo with objects defined in the values of
        bar (set of partitions).
        Returns a list of all objects included in list, but not dict values.
        """
        res = []
        for o in foo:
            if not compat.object_in_list(type(o), bar):
                res.append(o)
            elif not compat.object_in_list(o, bar[type(o)]):
                res.append(o)
        return res

    # Create partitions of both lists. This will reduce the time required for
    # the comparison
    left_objects = partition(left)
    right_objects = partition(right)
    # and then do the diff
    res['+'] = get_not_included(right, left_objects)
    res['-'] = get_not_included(left, right_objects)
    return res
def get_diff ( left , right ) : res = { '+' : [ ] , '-' : [ ] } def partition ( objects ) : res = { } for o in objects : t = type ( o ) if type ( o ) not in res : res [ t ] = [ ] res [ t ] . append ( o ) return res def get_not_included ( foo , bar ) : res = [ ] for o in foo : if not compat . object_in_list ( type ( o ) , bar ) : res . append ( o ) elif not compat . object_in_list ( o , bar [ type ( o ) ] ) : res . append ( o ) return res left_objects = partition ( left ) right_objects = partition ( right ) res [ '+' ] = get_not_included ( right , left_objects ) res [ '-' ] = get_not_included ( left , right_objects ) return res
Get the difference of both lists.

    The result will be a dict with this form {'+': [], '-': []}.
    Items listed in '+' exist only in the right list,
    items listed in '-' exist only in the left list.