diff options
author | Dag Wieers <dag@wieers.com> | 2016-11-17 15:08:12 +0100 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2016-11-17 18:33:04 +0100 |
commit | 1ca4add91c4d813c0bc054e0664fa8fbaf20aff0 (patch) | |
tree | 676761a4483ef951dd416aa9c365a69010d87c06 /contrib/inventory/abiquo.py | |
parent | Add playbook and packer file for building httptester (#18107) (diff) | |
download | ansible-1ca4add91c4d813c0bc054e0664fa8fbaf20aff0.tar.xz ansible-1ca4add91c4d813c0bc054e0664fa8fbaf20aff0.zip |
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 'contrib/inventory/abiquo.py')
-rwxr-xr-x | contrib/inventory/abiquo.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/inventory/abiquo.py b/contrib/inventory/abiquo.py index cd068e482b..04f7d4e60d 100755 --- a/contrib/inventory/abiquo.py +++ b/contrib/inventory/abiquo.py @@ -149,15 +149,15 @@ def generate_inv_from_api(enterprise_entity,config): vm_state = False if not vm_nic == None and vm_state: - if not vm_vapp in inventory.keys(): + if vm_vapp not in inventory: inventory[vm_vapp] = {} inventory[vm_vapp]['children'] = [] inventory[vm_vapp]['hosts'] = [] - if not vm_vdc in inventory.keys(): + if vm_vdc not in inventory: inventory[vm_vdc] = {} inventory[vm_vdc]['hosts'] = [] inventory[vm_vdc]['children'] = [] - if not vm_template in inventory.keys(): + if vm_template not in inventory: inventory[vm_template] = {} inventory[vm_template]['children'] = [] inventory[vm_template]['hosts'] = [] |