Changeset 1008:a23c222a0ddd


Ignore:
Timestamp:
Dec 25, 2010, 6:04:50 PM (11 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Provide `__lt__` for nodes in addition to `__cmp__`.

On my system, this reduces the running time for larger caches to
about 60 %.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lrucache.py

    r812 r1008  
    4545# the suffix after the hyphen denotes modifications by the
    4646#  ftputil project with respect to the original version
    47 __version__ = "0.2-2"
     47__version__ = "0.2-3"
    4848__all__ = ['CacheKeyError', 'LRUCache', 'DEFAULT_SIZE']
    4949__docformat__ = 'reStructuredText en'
     
    110110            self.mtime = self.atime
    111111            self._sort_key = sort_key
     112
     113        def __lt__(self, other):
     114            # Seems to be preferred over `__cmp__`, at least in newer
     115            #  Python versions. Uses only around 60 % of the time
     116            #  with respect to `__cmp__`.
     117            return self._sort_key < other._sort_key
    112118
    113119        def __cmp__(self, other):
Note: See TracChangeset for help on using the changeset viewer.