From ffb80926cec57125e9e0762dafd414f35d1e2d14 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 17 Nov 2016 15:08:12 +0100 Subject: [PATCH] Performance improvement using in-operator on dicts Just a small cleanup for the existing occurances. Using the in-operator for hash lookups is faster than using .keys() http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output --- lib/ansible/module_utils/facts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 066143defe0..9eb62b11f54 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2782,11 +2782,11 @@ class GenericBsdIfconfigNetwork(Network): return ifinfo = interfaces[defaults['interface']] # copy all the interface values across except addresses - for item in ifinfo.keys(): + for item in ifinfo: if item != 'ipv4' and item != 'ipv6': defaults[item] = ifinfo[item] if len(ifinfo[ip_type]) > 0: - for item in ifinfo[ip_type][0].keys(): + for item in ifinfo[ip_type][0]: defaults[item] = ifinfo[ip_type][0][item]