John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/243049
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(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/49/243049/1
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"
--
To view, visit https://gerrit.wikimedia.org/r/243049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I00375411ca15658c22ae6bdb49588ec9f03b8c69
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Malafaya <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits