Merge two dicts of addable values
343708
def add_dicts(d1, d2):
    
    if d1 is None:
        return d2
    if d2 is None:
        return d1
    keys = set(d1)
    keys.update(set(d2))
    ret = {}
    for key in keys:
        v1 = d1.get(key)
        v2 = d2.get(key)
        if v1 is None:
            ret[key] = v2
        elif v2 is None:
            ret[key] = v1
        else:
            ret[key] = v1 + v2
    return ret
742648
def unite_dict(a, b):
    
    c = {}
    c.update(a)
    c.update(b)
    return c
829293
def merge_dict(lhs, rhs):
    
    assert isinstance(lhs, dict)
    assert isinstance(rhs, dict)
    for k, v in rhs.iteritems():
        if k not in lhs:
            lhs[k] = v
        else:
            lhs[k] = merge_dict(lhs[k], v)
    return lhs
512052
def _merge(d, u):
    
    for k, v in u.items():
        # if we have a mapping, recursively merge the values
        if isinstance(v, collections.Mapping):
            d[k] = _merge(d.get(k, {}), v)

        # if d (the dict to merge into) is a dict, just add the
        # value to the dict.
        elif isinstance(d, collections.MutableMapping):
            d[k] = v

        # otherwise if d (the dict to merge into) is not a dict (e.g. when
        # recursing into it, `d.get(k, {})` may not be a dict), then do what
        # `update` does and prefer the new value.
        #
        # this means that something like `{'foo': 1}` when updated with
        # `{'foo': {'bar': 1}}` would have the original value (`1`) overwritten
        # and would become: `{'foo': {'bar': 1}}`
        else:
            d = {k: v}

    return d
77194
def merge(self):
        """"""
        if isinstance(self.head, dict) and isinstance(self.update, dict):
            if not isinstance(self.root, dict):
                self.root = {}
            self._merge_dicts()
        else:
            self._merge_base_values()

        if self.conflict_set:
            raise MergeError('Dictdiffer Errors', self.conflicts)
667002
function merge(obj1, obj2) {
  var res = {}, attrname;

  for (attrname in obj1) {
    res[attrname] = obj1[attrname];
  }
  for (attrname in obj2) {
    res[attrname] = obj2[attrname];
  }
  return res;
}
287084
def merge_map(a, b):
    
    if isinstance(a, list) and isinstance(b, list):
        return a + b

    if not isinstance(a, dict) or not isinstance(b, dict):
        return b

    for key in b:
        a[key] = merge_map(a[key], b[key]) if key in a else b[key]
    return a
409005
def deep_merge(*dicts):
    
    result = {}
    for d in dicts:
        if not isinstance(d, dict):
            raise Exception('Can only deep_merge dicts, got {}'.format(d))
        for k, v in d.items():
            # Whenever the value is a dict, we deep_merge it. This ensures that
            # (a) we only ever merge dicts with dicts and (b) we always get a
            # deep(ish) copy of the dicts and are thus safe from accidental
            # mutations to shared state.
            if isinstance(v, dict):
                v = deep_merge(result.get(k, {}), v)
            result[k] = v
    return result
442766
def dict_isect_combine(dict1, dict2, combine_op=op.add):
    
    keys3 = set(dict1.keys()).intersection(set(dict2.keys()))
    dict3 = {key: combine_op(dict1[key], dict2[key]) for key in keys3}
    return dict3
1315858
def _merge(x, y):
    """"""
    merged = {**x, **y}

    xkeys = x.keys()

    for key in xkeys:
        if isinstance(x[key], dict) and key in y:
            merged[key] = _merge(x[key], y[key])

    return merged
890188
def merge(self, other):
        """"""
        for key, value in other.items():
            if key in self and (isinstance(self[key], Compound)
                                and isinstance(value, dict)):
                self[key].merge(value)
            else:
                self[key] = value
1069256
def dict_selective_merge(a, b, selection, path=None):
    
    if path is None:
        path = []
    for key in b:
        if key in selection:
            if key in a:
                if isinstance(a[key], dict) and isinstance(b[key], dict):
                    dict_selective_merge(a[key], b[key], b[key].keys(), path + [str(key)])
                elif a[key] != b[key]:
                    # update the value
                    a[key] = b[key]
            else:
                a[key] = b[key]
    return a
640396
def merge(self, dict_=None):
        """"""
        if dict_ is None and hasattr(self, '__dict__'):
            dict_ = self.__dict__  
            # doesn't work anymore as we have _lock attribute
        if dict_ is None:
            return self
        self.update(dict_)
        return self
780775
def _merge_dicts(first, second):
    """"""
    new = deepcopy(first)
    for k, v in second.items():
        if isinstance(v, dict) and v:
            ret = _merge_dicts(new.get(k, dict()), v)
            new[k] = ret
        else:
            new[k] = second[k]
    return new
295231
def merge(s, t):
    """"""

    for k, v in t.items():
        if isinstance(v, dict):
            if k not in s:
                s[k] = v
                continue

            s[k] = merge(s[k], v)
            continue

        s[k] = v

    return s
1332737
def merge_result(res):
    
    if not isinstance(res, dict):
        raise ValueError('Value should be of dict type')

    result = set([])

    for _, v in res.items():
        for value in v:
            result.add(value)

    return list(result)
930294
def dictionary_merge(a, b):
    
    for key, value in b.items():
        if key in a and isinstance(a[key], dict) and isinstance(value, dict):
            dictionary_merge(a[key], b[key])
            continue
        a[key] = b[key]
    return a