From 1df76ee42d93eabc1d878e9db2c497817cbd0d10 Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Mon, 12 Dec 2016 11:11:28 +0800 Subject: 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 --- oslo_serialization/jsonutils.py | 2 +- oslo_serialization/msgpackutils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'oslo_serialization') diff --git a/oslo_serialization/jsonutils.py b/oslo_serialization/jsonutils.py index e96c28a..7df6496 100644 --- a/oslo_serialization/jsonutils.py +++ b/oslo_serialization/jsonutils.py @@ -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 diff --git a/oslo_serialization/msgpackutils.py b/oslo_serialization/msgpackutils.py index af76c4c..4206ab4 100644 --- a/oslo_serialization/msgpackutils.py +++ b/oslo_serialization/msgpackutils.py @@ -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'): -- cgit v1.2.1