(one, two, keyfn, resolvefn)
return merged
Merges two lists. The algorithm is to first iterate over the first list. If the item in the first list
    does not exist in the second list, add that item to the merged list. If the item does exist in the second
    list, resolve the conflict using the resolvefn. After the first list has been iterated over, simply append
    any items in the second list that have not already been added. If the items in the list are objects,
    then the objects will be mutated directly and not copied.

    :param one: The first list to be merged.
    :param two: The second list to be merged.
    :param keyfn: A function that takes an element from the list as an argument and returns a unique
        identifier for that item.
    :param resolvefn: A function that takes two elements that resolve to the same key and returns a single
        element that has resolved the conflict between the two elements.
    :returns: A list of the merged elements
Merges two lists. The algorithm is to first iterate over the first list. If the item in the first list
    does not exist in the second list, add that item to the merged list. If the item does exist in the second
    list, resolve the conflict using the resolvefn. After the first list has been iterated over, simply append
    any items in the second list that have not already been added. If the items in the list are objects,
    then the objects will be mutated directly and not copied.
Merges two lists . The algorithm is to first iterate over the first list . If the item in the first list does not exist in the second list add that item to the merged list . If the item does exist in the second list resolve the conflict using the resolvefn . After the first list has been iterated over simply append any items in the second list that have not already been added . If the items in the list are objects then the objects will be mutated directly and not copied .
def _merge_lists(one, two, keyfn, resolvefn):
    """Merges two lists. The algorithm is to first iterate over the first list. If the item in the first list
    does not exist in the second list, add that item to the merged list. If the item does exist in the second
    list, resolve the conflict using the resolvefn. After the first list has been iterated over, simply append
    any items in the second list that have not already been added. If the items in the list are objects,
    then the objects will be mutated directly and not copied.

    :param one: The first list to be merged.
    :param two: The second list to be merged.
    :param keyfn: A function that takes an element from the list as an argument and returns a unique
        identifier for that item.
    :param resolvefn: A function that takes two elements that resolve to the same key and returns a single
        element that has resolved the conflict between the two elements.
    :returns: A list of the merged elements
    """

    merged = []

    two_keys = {keyfn(obj): obj for obj in two}

    for obj in one:
        obj_key = keyfn(obj)

        if obj_key in two_keys:
            # If obj exists in both list, must merge
            new_obj = resolvefn(
                obj,
                two_keys.pop(obj_key),
            )
        else:
            new_obj = obj

        merged.append(new_obj)

    # Get the rest of the objects in the second list
    merged.extend(list(two_keys.values()))
    return merged
def _merge_lists ( one , two , keyfn , resolvefn ) : merged = [ ] two_keys = { keyfn ( obj ) : obj for obj in two } for obj in one : obj_key = keyfn ( obj ) if obj_key in two_keys : # If obj exists in both list, must merge new_obj = resolvefn ( obj , two_keys . pop ( obj_key ) , ) else : new_obj = obj merged . append ( new_obj ) # Get the rest of the objects in the second list merged . extend ( list ( two_keys . values ( ) ) ) return merged