Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1007342?usp=email )

Change subject: [IMPR] remove sorting from page_gen generator
......................................................................

[IMPR] remove sorting from page_gen generator

The page_gen method retrieves pages by the get_page() index which
lies within start and end parameters. The sorting key is found by
get_number() function which gives the same value which is previously
given by the index of get_page. Therefore the sorting is needless but
the sorting build-in function is greedy and retrieves all pages which
is not in the sense of the generator.

Change-Id: Ibbcf55f02500fd1c0bd4e95bcac267aded4fc777
---
M pywikibot/proofreadpage.py
1 file changed, 17 insertions(+), 9 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index b28b9fa..e75f397 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -1316,8 +1316,6 @@

         Range is [start ... end], extremes included.

-        .. versionchanged:: 8.6
-           page names are sorted before loading pages.
         .. versionchanged:: 9.0
            The *content* parameter was removed

@@ -1339,13 +1337,7 @@
             filter_ql = list(self.site.proofread_levels)
             filter_ql.remove(ProofreadPage.WITHOUT_TEXT)

-        gen = [self.get_page(i) for i in range(start, end + 1)]
-
-        # Decorate and sort by page number because preloadpages does not
-        # guarantee order.
-        # TODO: remove if preloadpages will guarantee order.
-        gen = [(self.get_number(p), p) for p in gen]
-        gen = [p for n, p in sorted(gen)]
+        gen = (self.get_page(i) for i in range(start, end + 1))

         gen = self.site.preloadpages(gen)
         # Filter by QL.

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1007342?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibbcf55f02500fd1c0bd4e95bcac267aded4fc777
Gerrit-Change-Number: 1007342
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to