def keyrename(d, mapping):
    """Change all keys in dictionary ``d`` according to
    ``mapping``. Modifies ``d`` in place!

    :param d: The dictionary to change
    :type d: dict

    :param mapping: The keys to change and to what to change them
    :type mapping: iterable of 2-tuples

    """

    for frm, to in mapping:
        d[to] = d.pop(frm)
    return d