Revision: 6637 Author: cosoleto Date: 2009-04-19 13:32:13 +0000 (Sun, 19 Apr 2009)
Log Message: ----------- Using dictionary instead of sets produces faster code execution. Suggested by Nicolas (see also http://article.gmane.org/gmane.comp.python.pywikipediabot.general/10292).
Modified Paths: -------------- trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2009-04-19 13:12:12 UTC (rev 6636) +++ trunk/pywikipedia/pagegenerators.py 2009-04-19 13:32:13 UTC (rev 6637) @@ -705,11 +705,11 @@ Wraps around another generator. Yields all pages, but prevents duplicates. """ - seenPages = set() + seenPages = dict() for page in generator: _page = u"%s:%s:%s" % (page._site.family.name, page._site.lang, page._title) if _page not in seenPages: - seenPages.add(_page) + seenPages[_page] = True yield page
def RegexFilterPageGenerator(generator, regex):
pywikipedia-svn@lists.wikimedia.org