performance optimisation in hash merge logic

rewrite deepcopy in util.merge_hash and just iterate
on an inventory with 500 groups and 800 hosts this brings back the
inventory initialisation from 13s to 3s (with hash_behaviour=merge)
parent d4634983
......@@ -558,10 +558,11 @@ def merge_hash(a, b):
''' recursively merges hash b into a
keys from b take precedence over keys from a '''
result = copy.deepcopy(a)
result = {}
for dicts in a, b:
# next, iterate over b keys and values
for k, v in b.iteritems():
for k, v in dicts.iteritems():
# if there's already such key in a
# and that key contains dict
if k in result and isinstance(result[k], dict):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment