Revision: 6754 Author: nicdumz Date: 2009-04-29 21:45:15 +0000 (Wed, 29 Apr 2009)
Log Message: ----------- Use self.cache as a... cache! If the last entry has the key we're looking for, return its value.
Modified Paths: -------------- trunk/pywikipedia/diskcache.py
Modified: trunk/pywikipedia/diskcache.py =================================================================== --- trunk/pywikipedia/diskcache.py 2009-04-29 21:41:21 UTC (rev 6753) +++ trunk/pywikipedia/diskcache.py 2009-04-29 21:45:15 UTC (rev 6754) @@ -92,6 +92,13 @@ self.cache.remove((k, v)) self.cache.append((k, v))
+ try: + k, v = self.cache[-1] + if k == key: + return v + except IndexError: + pass + self.cache_file.seek(self.lookup[i]) while True: length = int(self.read(2, key), 16)
pywikipedia-svn@lists.wikimedia.org