Ticket #32: lrucache.patch

File lrucache.patch, 1.0 kB (added by schwa, 16 months ago)

Patch against lrucache.py to use the modified heapq module ftputil_heapq.py

  • .py

    old new  
    4040 
    4141from __future__ import generators 
    4242import time 
    43 from heapq import heappush, heappop, heapify 
     43from ftputil_heapq import heappush, heappop, heapify 
    4444 
    4545__version__ = "0.2" 
    4646__all__ = ['CacheKeyError', 'LRUCache', 'DEFAULT_SIZE'] 
     
    177177            yield node.key 
    178178        raise StopIteration 
    179179 
     180    def print_heap(self): 
     181        for item in self.__heap: 
     182            print "  ", item.key 
     183 
    180184    def __setattr__(self, name, value): 
    181185        object.__setattr__(self, name, value) 
    182186        # automagically shrink heap on resize 
    183187        if name == 'size': 
    184188            while len(self.__heap) > value: 
     189                #print "Before heappop" 
     190                #self.print_heap() 
    185191                lru = heappop(self.__heap) 
     192                #print "After heappop" 
     193                #print lru.key 
     194                #self.print_heap() 
    186195                del self.__dict[lru.key] 
    187196 
    188197    def __repr__(self):