Replace six.iteritems/itervalues with dict.items()/values()
1.As mentioned in [1], we should avoid using six.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items/keys will more readable. 2.In py2, the performance about list should be negligible, see the link [2]. [1] https://wiki.openstack.org/wiki/Python3 [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I88c133a37a11ef9049766a151a134106440bef6a
This commit is contained in:
parent
b7b9e13de6
commit
9f7bf67b87
@ -132,7 +132,7 @@ def _get_file_contents(from_data, files):
|
|||||||
if not isinstance(from_data, (dict, list)):
|
if not isinstance(from_data, (dict, list)):
|
||||||
return
|
return
|
||||||
if isinstance(from_data, dict):
|
if isinstance(from_data, dict):
|
||||||
recurse_data = six.itervalues(from_data)
|
recurse_data = from_data.values()
|
||||||
for key, value in from_data.items():
|
for key, value in from_data.items():
|
||||||
if _ignore_if(key, value):
|
if _ignore_if(key, value):
|
||||||
continue
|
continue
|
||||||
|
@ -319,7 +319,7 @@ resource_types = {
|
|||||||
|
|
||||||
|
|
||||||
def get_resource_type(type):
|
def get_resource_type(type):
|
||||||
for key, value in six.iteritems(resource_types):
|
for key, value in resource_types.items():
|
||||||
if key in type:
|
if key in type:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user