def find_playlist_changes(orig_tracks, modified_tracks):
    """Finds the changes between two playlists.

    Returns a tuple of (deletions, additions, staying).
    Deletions and additions are both Counters of (sid, eid) tuples;
    staying is a set of (sid, eid) tuples.

    :param old: the original playlist.
    :param modified: the modified playlist."""

    s_pairs = get_id_pairs(orig_tracks)

    # Three cases for desired pairs:
    # 1: (sid, eid from this playlist): either no action or add
    #    (if someone adds a dupe from the same playlist)
    # 2: (sid, eid not from this playlist): add
    # 3: (sid, None): add
    d_pairs = get_id_pairs(modified_tracks)

    # Counters are multisets.
    s_count = Counter(s_pairs)
    d_count = Counter(d_pairs)

    to_del = s_count - d_count
    to_add = s_count - d_count
    to_keep = set(s_count & d_count)  # guaranteed to be counts of 1

    return (to_del, to_add, to_keep)
dataset/ETHPy150Open simon-weber/gmusicapi/gmusicapi/gmtools/tools.py/find_playlist_changes/swapped operands of `-`