def _compare_sequence(a, b):
    """Compares the elements of a list/tuple `a`
    and a list/tuple `b`.  `_compare_sequence((1,2), [1, 2])`
    is True, whereas `(1,2) == [1, 2]` is False"""
    if type(a) is type(b):
        # if they are the same type, compare directly
        return a == b
    # there is no overhead for calling `tuple` on a
    # tuple
    return tuple(a) == tuple(b)