jenkins-bot has submitted this change and it was merged.
Change subject: Improve page depth counting efficiency
......................................................................
Improve page depth counting efficiency
We don't need to listify a re.finditer result in order to count
the number of forward slashes that appear in a page title - all
we have to do is use the built-in function string.count(substr).
Change-Id: Ia457c837380f4681046bca64243b826e3ae7a302
---
M pywikibot/page.py
1 file changed, 1 insertion(+), 2 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index a59d379..5c5f2e0 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -235,8 +235,7 @@
if not hasattr(self, '_depth'):
# Check if the namespace allows subpages
if self._namespace_obj.subpages:
- # Count how many '/'s we have in the title
- _depth = len(list(re.finditer('/', self.title())))
+ _depth = self.title().count('/')
else:
# Does not allow subpages, which means depth is always 0
_depth = 0
--
To view, visit
https://gerrit.wikimedia.org/r/297117
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia457c837380f4681046bca64243b826e3ae7a302
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: APerson <danielhglus(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Sn1per <geofbot(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>