def get_dict_diff(d1, d2):
def _diff(d1_, d2_, namespace):<EOL><INDENT>added = []<EOL>removed = []<EOL>changed = []<EOL>for k1, v1 in d1_.iteritems():<EOL><INDENT>if k1 not in d2_:<EOL><INDENT>removed.append(namespace + [k1])<EOL><DEDENT>else:<EOL><INDENT>v2 = d2_[k1]<EOL>if v2 != v1:<EOL><INDENT>if isinstance(v1, dict) and isinstance(v2, dict):<EOL><INDENT>namespace_ = namespace + [k1]<EOL>added_, removed_, changed_ = _diff(v1, v2, namespace_)<EOL>added.extend(added_)<EOL>removed.extend(removed_)<EOL>changed.extend(changed_)<EOL><DEDENT>else:<EOL><INDENT>changed.append(namespace + [k1])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for k2 in d2_.iterkeys():<EOL><INDENT>if k2 not in d1_:<EOL><INDENT>added.append(namespace + [k2])<EOL><DEDENT><DEDENT>return added, removed, changed<EOL><DEDENT>return _diff(d1, d2, [])<EOL>
Get added/removed/changed keys between two dicts.

    Each key in the return value is a list, which is the namespaced key that
    was affected.

    Returns:
        3-tuple:
        - list of added keys;
        - list of removed key;
        - list of changed keys.