Replace six iteration methods with standard ones

1.As mentioned in [1], we should avoid using six.iterXXX
to achieve iterators. We can use dict.XXX instead, as it will
return iterators in PY3 as well.

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: I35b6c00d6ce7c6dd535932c97c071ae4d5f503e3
This commit is contained in:
Luong Anh Tuan 2016-09-23 15:52:59 +07:00 committed by Tuan Luong-Anh
parent 517083e999
commit cbb99f97b0

View File

@ -648,10 +648,7 @@ class PortPidState(object):
Yield all current listen sockets.
"""
# Use six.itervalues() instead of calling directly the .values() method
# on Python 2 to avoid a temporary list, because sock_data_by_port
# comes from users and can be large.
for orphan_data in six.itervalues(self.sock_data_by_port):
for orphan_data in self.sock_data_by_port.values():
yield orphan_data['sock']
def forget_port(self, port):