jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1325848?usp=email )

Change subject: tools: Reduce merge_unique_dicts allocations
......................................................................

tools: Reduce merge_unique_dicts allocations

Iterate over the supplied dictionaries without copying argument containers.
Detect duplicate keys through result membership instead of temporary key sets.

Change-Id: Ie8292bbaa137d74d6b0b9aea9c1904182b7a42d7
---
M pywikibot/tools/__init__.py
1 file changed, 2 insertions(+), 3 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 9931e4b..6c84579 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -830,11 +830,10 @@

     .. version-added:: 3.0
     """
-    args = [*list(args), dict(kwargs)]
     conflicts = set()
     result = {}
-    for arg in args:
-        conflicts |= set(arg.keys()) & set(result.keys())
+    for arg in (*args, kwargs):
+        conflicts.update(key for key in arg if key in result)
         result.update(arg)
     if conflicts:
         raise ValueError('Multiple dicts contain the same keys: {}'

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1325848?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: Ie8292bbaa137d74d6b0b9aea9c1904182b7a42d7
Gerrit-Change-Number: 1325848
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]

Reply via email to