jenkins-bot has submitted this change and it was merged.
Change subject: interwiki.py: check for category before emptiness ......................................................................
interwiki.py: check for category before emptiness
Currently, page.isEmpty() requires parsing the whole page and doing some removals (langlinks and categories) which takes up significant CPU time. There are 2 checks which use page.isEmpty() as the starting condition while having a much simpler second condition of just checking the page namespace. In this patch, I reversed the checks order. For categories, the time taken in batchLoaded() is reduced to about 30% of the original time.
Change-Id: I00375411ca15658c22ae6bdb49588ec9f03b8c69 (cherry picked from commit 330ebe54492c9cf7c787a3c272872d778ba34fab) --- M scripts/interwiki.py 1 file changed, 2 insertions(+), 2 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Malafaya: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/scripts/interwiki.py b/scripts/interwiki.py index fa26860..ca83ff4 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -1364,7 +1364,7 @@
# must be behind the page.isRedirectPage() part # otherwise a redirect error would be raised - elif page.isEmpty() and not page.isCategory(): + elif not page.isCategory() and page.isEmpty(): globalvar.remove.append(unicode(page)) if not globalvar.quiet: pywikibot.output(u"NOTE: %s is empty. Skipping." % page) @@ -1449,7 +1449,7 @@ pywikibot.output(u'File autonomous_problems.dat open or corrupted! Try again with -restore.') sys.exit() iw = () - elif page.isEmpty() and not page.isCategory(): + elif not page.isCategory() and page.isEmpty(): globalvar.remove.append(unicode(page)) if not globalvar.quiet: pywikibot.output(u"NOTE: %s is empty; ignoring it and its interwiki links"