diff options
author | Dag Wieers <dag@wieers.com> | 2016-11-17 15:32:05 +0100 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2016-11-17 10:11:38 -0500 |
commit | 8c1c499d9d1c87f288122aebf8dfa4320e55bc7b (patch) | |
tree | a97df61c24395668eb5011dd725443946571515b /network | |
parent | 3031764ce0c2ce8f79323ca7043d26854c94355a (diff) | |
download | ansible-modules-extras-8c1c499d9d1c87f288122aebf8dfa4320e55bc7b.tar.gz |
Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences.
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
Diffstat (limited to 'network')
-rw-r--r-- | network/haproxy.py | 4 | ||||
-rw-r--r-- | network/snmp_facts.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/network/haproxy.py b/network/haproxy.py index 0d1db039..0ab17549 100644 --- a/network/haproxy.py +++ b/network/haproxy.py @@ -196,10 +196,10 @@ class HAProxy(object): """ Capture the output for a command """ - if not 'command' in self.command_results.keys(): + if 'command' not in self.command_results: self.command_results['command'] = [] self.command_results['command'].append(cmd) - if not 'output' in self.command_results.keys(): + if 'output' not in self.command_results: self.command_results['output'] = [] self.command_results['output'].append(output) diff --git a/network/snmp_facts.py b/network/snmp_facts.py index 28546dfc..1411b802 100644 --- a/network/snmp_facts.py +++ b/network/snmp_facts.py @@ -153,7 +153,7 @@ def lookup_adminstatus(int_adminstatus): 2: 'down', 3: 'testing' } - if int_adminstatus in adminstatus_options.keys(): + if int_adminstatus in adminstatus_options: return adminstatus_options[int_adminstatus] else: return "" @@ -168,7 +168,7 @@ def lookup_operstatus(int_operstatus): 6: 'notPresent', 7: 'lowerLayerDown' } - if int_operstatus in operstatus_options.keys(): + if int_operstatus in operstatus_options: return operstatus_options[int_operstatus] else: return "" |