mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-08-14 06:54:55 -05:00
Use Python3-compatible dict method names
Python 2 has keys()/values()/items(), which return lists, iterkeys()/itervalues()/iteritems(), which return iterators, and viewkeys()/viewvalues()/viewitems() which return views. Python 3 has only keys()/values()/items(), which return views. To get iterators, one can use iter() or a for loop/comprehension; for lists there's the list() constructor. When iterating through the entire dict, without modifying the dict, the difference between Python 2's items() and iteritems() is negligible, especially on small dicts (the main overhead is extra memory, not CPU time). In the interest of simpler code, this patch changes many instances of iteritems() to items(), iterkeys() to keys() etc. In other cases, helpers like six.itervalues are used. Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
dd16cc98b0
commit
3bf91eab25
@@ -28,6 +28,8 @@ import json
|
||||
import time
|
||||
import collections
|
||||
|
||||
import six
|
||||
|
||||
import ipalib
|
||||
from ipapython import ipautil
|
||||
from ipaplatform.paths import paths
|
||||
@@ -78,7 +80,7 @@ class KnownServices(collections.Mapping):
|
||||
return len(self.__d)
|
||||
|
||||
def __call__(self):
|
||||
return self.__d.itervalues()
|
||||
return six.itervalues(self.__d)
|
||||
|
||||
def __getattr__(self, name):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user