import copy


def merge_dict(a, b):
    """Merge the fields of a and b, the latter overriding the former."""
    res = copy.deepcopy(a) if a else {}
    copyb = copy.deepcopy(b) if b else {}
    for key in copyb:
        res[key] = copyb[key]
    return res