def rekey_map(mapping, replacements):
    """Given an iterable of destination/source pairs in replacements,
    create a new dict that is the same as the original except for the
    new key names."""
    result = dict(mapping)
    for dst, src in replacements:
        value = result[src]
        result[dst] = value
        del result[src]
    return result