jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1328668?usp=email )
Change subject: api: Cache query module keys
......................................................................
api: Cache query module keys
Cache query module names when constructing a QueryGenerator.
Reuse the frozen set while counting results to avoid rebuilding module sets for
every item.
Change-Id: I61eceb5c6c9a7f7c31de1fa9c6077b2bf0e09c0b
---
M pywikibot/data/api/_generators.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/data/api/_generators.py
b/pywikibot/data/api/_generators.py
index 8a2d2e3..002b35c 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -306,6 +306,7 @@
for modtype in ('generator', 'list', 'prop', 'meta'):
if modtype in parameters:
self.modules = parameters[modtype].split('|')
+ self._module_keys = frozenset(self.modules)
break
else:
raise Error(f'{type(self).__name__}: No query module name found'
@@ -655,7 +656,7 @@
yield result
- modules_item_intersection = set(self.modules) & set(item)
+ modules_item_intersection = self._module_keys.intersection(item)
if isinstance(item, dict) and modules_item_intersection:
# Count elements contained in sub-items.
# If we need to count elements contained in items in
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1328668?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I61eceb5c6c9a7f7c31de1fa9c6077b2bf0e09c0b
Gerrit-Change-Number: 1328668
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]