docs: def union(dict1, dict2):
      """
      Deep merge of dict2 into dict1.  May be dictionaries or dictobj's.
      Values in dict2 will replace values in dict1 where they vary but have
      the same key.
  
      When lists are encountered, the dict2 list will replace the dict1 list.
  
      This will alter the first dictionary.  The returned result is dict1, but
      it will have references to both dictionaries.  If you do not want this,
      use union_copy(), which is less efficient but data-safe.
  
      >>> a = dict(a=dict(b=dict(c=1)))
      >>> b = dict(a=dict(b=dict(d=2)),e=[1,2])
      >>> # sorted json so that it is predictably the same
      >>> import json
      >>> json.dumps(union(a, b), sort_keys=True)
      '{"a": {"b": {"c": 1, "d": 2}}, "e": [1, 2]}'
      >>> json.dumps(a, sort_keys=True)
      '{"a": {"b": {"c": 1, "d": 2}}, "e": [1, 2]}'
      >>> json.dumps(b, sort_keys=True)
      '{"a": {"b": {"d": 2}}, "e": [1, 2]}'
      >>> a['e'][0] = 3
      >>> json.dumps(a, sort_keys=True)
      '{"a": {"b": {"c": 1, "d": 2}}, "e": [3, 2]}'
      >>> json.dumps(b, sort_keys=True)
      '{"a": {"b": {"d": 2}}, "e": [3, 2]}'
      """
      for key, value in dict2.items():
          if key in dict1 and isinstance(value, dict):
              dict1[key] = union(dict1[key], value)
          else:
              dict1[key] = value
      return dict1