jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/433547 )
Change subject: [IMPR] Don't use a list for lookup
......................................................................
[IMPR] Don't use a list for lookup
Searching in a list is O(n) whereas searching in a set is O(1).
Use a set for the seen lookup table and improve the speed a lot.
Change-Id: I140ffc533a2ffd5acfda2552da37e8091af6feb6
---
M scripts/watchlist.py
1 file changed, 5 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index 3da8e4a..716f424 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -18,7 +18,7 @@
"""
#
# (C) Daniel Herding, 2005
-# (C) Pywikibot team, 2005-2017
+# (C) Pywikibot team, 2005-2018
#
# Distributed under the terms of the MIT license.
#
@@ -59,16 +59,15 @@
"""Reload watchlists for all wikis where a watchlist is already
present."""
cache_path = CachedRequest._get_cache_dir()
files = os.listdir(cache_path)
- seen = []
+ seen = set()
for filename in files:
entry = CacheEntry(cache_path, filename)
entry._load_cache()
entry.parse_key()
entry._rebuild()
- if entry.site not in seen:
- if entry._data.get('watchlistraw'):
- refresh(entry.site, sysop)
- seen.append(entry.site)
+ if entry.site not in seen and 'watchlistraw' in entry._data:
+ refresh(entry.site, sysop)
+ seen.add(entry.site)
def refresh_new(sysop=False):
--
To view, visit
https://gerrit.wikimedia.org/r/433547
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I140ffc533a2ffd5acfda2552da37e8091af6feb6
Gerrit-Change-Number: 433547
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>