jenkins-bot merged this change.
[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.