jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/416333 )
Change subject: category_redirect.py: convert dict_keys to list when iterating ......................................................................
category_redirect.py: convert dict_keys to list when iterating
In Python 3, dict.keys() is a dynamic iterator that checks the dict to ensure it is not modified during the iterations, so Python is able to use less memory as it does not have to always construct the whole list like in Python 2. Converting it to a list will make it behave like Python 2, where the list of keys is static, with a larger memory use.
Since the entire dict is in memory and nobody complained while they are running this script in Python 2, it's probably safe to assume the additional memory overhead is not too bad and we don't have to make famcy code to avoid list().
Bug: T188850 Change-Id: I44f934396398799a1478e4cd3ccf8ecee9b86397 --- M scripts/category_redirect.py 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: Dvorapa: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py index 6c699d5..285651c 100755 --- a/scripts/category_redirect.py +++ b/scripts/category_redirect.py @@ -346,7 +346,7 @@ pass
# delete record entries for non-existent categories - for cat_name in record.keys(): + for cat_name in list(record.keys()): if pywikibot.Category(self.site, self.catprefix + cat_name) not in catpages: del record[cat_name]
pywikibot-commits@lists.wikimedia.org