def dict_update(mydict, other, keylist=None):
    """update mydict with other but do not change existing values.

    If keylist is given, update only these keys.
    """
    if keylist is None:
        keylist = list(other.keys())
    for k in keylist:
        v = other[k]
        old_v = mydict.get(k)
        if old_v is None:
            mydict[k] = v
            continue
        if old_v == v:
            continue
        raise ValueError('key %s: contradicting values: %s %s' % (k, repr(
            old_v), repr(v)))
