Replace six.iteritems() with .items()
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: Ifbe7929580ec61a2cd50232794c0cbd0cbf37edc
This commit is contained in:
parent
58ee9d8ca2
commit
1df76ee42d
@ -150,7 +150,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,
|
||||
encoding=encoding)
|
||||
if isinstance(value, dict):
|
||||
return {recursive(k): recursive(v)
|
||||
for k, v in six.iteritems(value)}
|
||||
for k, v in value.items()}
|
||||
elif hasattr(value, 'iteritems'):
|
||||
return recursive(dict(value.iteritems()), level=level + 1)
|
||||
# Python 3 does not have iteritems
|
||||
|
@ -172,7 +172,7 @@ class HandlerRegistry(object):
|
||||
def copy(self, unfreeze=False):
|
||||
"""Deep copy the given registry (and its handlers)."""
|
||||
c = type(self)()
|
||||
for ident, handlers in six.iteritems(self._handlers):
|
||||
for ident, handlers in self._handlers.items():
|
||||
cloned_handlers = []
|
||||
for h in handlers:
|
||||
if hasattr(h, 'copy'):
|
||||
|
Loading…
Reference in New Issue
Block a user