jenkins-bot merged this change.

View Change

Approvals: Framawiki: Looks good to me, approved jenkins-bot: Verified
[IMPR] improve hash method for BasePage and Link

- use _cmpkey to build hash BasePage
- simplify Link's hash method by using sitename and canonical_title as tuple

Change-Id: I346b050665b3337cca0ff9e22e8d493547b2a7af
---
M pywikibot/page.py
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index e2f2fcc..46021a9 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -413,7 +413,7 @@
This relies on the fact that the string
representation of an instance can not change after the construction.
"""
- return hash(unicode(self))
+ return hash(self._cmpkey())

def full_url(self):
"""Return the full URL."""
@@ -5846,9 +5846,7 @@

def __hash__(self):
"""A stable identifier to be used as a key in hash-tables."""
- return hash(u'%s:%s:%s' % (self.site.family.name,
- self.site.code,
- self.title))
+ return hash((self.site.sitename, self.canonical_title()))

@classmethod
def fromPage(cls, page, source=None):

To view, visit change 453576. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I346b050665b3337cca0ff9e22e8d493547b2a7af
Gerrit-Change-Number: 453576
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Matěj Suchánek <matejsuchanek97@gmail.com>