Mercurial > p > roundup > code
diff roundup/backends/indexer_dbm.py @ 5395:23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Tool-assisted patch. Changes of iterkeys / itervalues / iteritems to
keys / values / items are fully automated, but may make things less
efficient in Python 2. Automated tools want to add list() around many
calls to keys / values / items, but I thought most such list()
additions were unnecessary because it seemed the result of keys /
values / items was just iterated over while the set of dict keys
remained unchanged, rather than used in a way requiring an actual
list, or used while the set of keys in the dict could change. It's
quite possible I missed some cases where list() was really needed, or
left in some unnecessary list() calls.
In cases where list() was only needed because the resulting list was
then sorted in-place, I changed the code to use calls to sorted().
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 23:04:42 +0000 |
| parents | 64c4e43fbb84 |
| children | e2baa4e6ed6d |
line wrap: on
line diff
--- a/roundup/backends/indexer_dbm.py Tue Jul 24 23:03:35 2018 +0000 +++ b/roundup/backends/indexer_dbm.py Tue Jul 24 23:04:42 2018 +0000 @@ -204,7 +204,7 @@ dbslice = marshal.loads(pickle_str) if dbslice.get('WORDS'): # if it has some words, add them - for word, entry in dbslice['WORDS'].iteritems(): + for word, entry in dbslice['WORDS'].items(): db['WORDS'][word] = entry if dbslice.get('FILES'): # if it has some files, add them @@ -240,7 +240,7 @@ segdicts = {} # Need batch of empty dicts for segment in letters: segdicts[segment] = {} - for word, entry in self.words.iteritems(): # Split into segment dicts + for word, entry in self.words.items(): # Split into segment dicts initchar = word[0].upper() segdicts[initchar][word] = entry @@ -269,7 +269,7 @@ del self.fileids[file_index] # The much harder part, cleanup the word index - for key, occurs in self.words.iteritems(): + for key, occurs in self.words.items(): if file_index in occurs: del occurs[file_index]
