def _create_diffs_for_mappings(current_path, mapping_a, mapping_b):
 resulting_diffs = pvector([]).evolver()
 a_keys = frozenset(mapping_a.keys())
 b_keys = frozenset(mapping_b.keys())
 for key in a_keys.intersection(b_keys):
  if (mapping_a[key] != mapping_b[key]):
   resulting_diffs.extend(_create_diffs_for(current_path.append(key), mapping_a[key], mapping_b[key]))
 for key in b_keys.difference(a_keys):
  resulting_diffs.append(_Set(path=current_path, key=key, value=mapping_b[key]))
 for key in a_keys.difference(b_keys):
  resulting_diffs.append(_Remove(path=current_path, item=key))
 return resulting_diffs.persistent()

def _create_diffs_for_mappings ( current_path , mapping_a , mapping_b ) : resulting_diffs = pvector ( [ ] ) . evolver ( ) a_keys = frozenset ( mapping_a . keys ( ) ) b_keys = frozenset ( mapping_b . keys ( ) ) for key in a_keys . intersection ( b_keys ) : if ( mapping_a [ key ] != mapping_b [ key ] ) : resulting_diffs . extend ( _create_diffs_for ( current_path . append ( key ) , mapping_a [ key ] , mapping_b [ key ] ) ) for key in b_keys . difference ( a_keys ) : resulting_diffs . append ( _Set ( path = current_path , key = key , value = mapping_b [ key ] ) ) for key in a_keys . difference ( b_keys ) : resulting_diffs . append ( _Remove ( path = current_path , item = key ) ) return resulting_diffs . persistent ( )
computes a series of _idiffchange s to turn mapping_a into mapping_b assuming that these mappings are at current_path inside a nested pyrsistent object .