diff options
| author | Brett Cannon <brett@python.org> | 2013-06-14 22:33:21 (GMT) | 
|---|---|---|
| committer | Brett Cannon <brett@python.org> | 2013-06-14 22:33:21 (GMT) | 
| commit | 8c18da20f979cf428414a038bfaee46283e12fa2 (patch) | |
| tree | f58a84e784555673c6e7b813846e5fc40ea2c27b /Lib/filecmp.py | |
| parent | 33915eba7c8293eab4962345fbbb1e5d193295ed (diff) | |
| parent | 7bff3cbe3de7bc96575396ad3fd7bfc6058eaa94 (diff) | |
| download | cpython-8c18da20f979cf428414a038bfaee46283e12fa2.zip cpython-8c18da20f979cf428414a038bfaee46283e12fa2.tar.gz cpython-8c18da20f979cf428414a038bfaee46283e12fa2.tar.bz2  | |
merge
Diffstat (limited to 'Lib/filecmp.py')
| -rw-r--r-- | Lib/filecmp.py | 11 | 
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/filecmp.py b/Lib/filecmp.py index 014c0d0..3285288 100644 --- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -6,6 +6,7 @@ Classes:  Functions:      cmp(f1, f2, shallow=True) -> int      cmpfiles(a, b, common) -> ([], [], []) +    clear_cache()  """ @@ -13,7 +14,7 @@ import os  import stat  from itertools import filterfalse -__all__ = ['cmp', 'dircmp', 'cmpfiles', 'DEFAULT_IGNORES'] +__all__ = ['clear_cache', 'cmp', 'dircmp', 'cmpfiles', 'DEFAULT_IGNORES']  _cache = {}  BUFSIZE = 8*1024 @@ -21,6 +22,9 @@ BUFSIZE = 8*1024  DEFAULT_IGNORES = [      'RCS', 'CVS', 'tags', '.git', '.hg', '.bzr', '_darcs', '__pycache__'] +def clear_cache(): +    """Clear the filecmp cache.""" +    _cache.clear()  def cmp(f1, f2, shallow=True):      """Compare two files. @@ -39,7 +43,8 @@ def cmp(f1, f2, shallow=True):      True if the files are the same, False otherwise.      This function uses a cache for past comparisons and the results, -    with a cache invalidation mechanism relying on stale signatures. +    with a cache invalidation mechanism relying on stale signatures +    or by explicitly calling clear_cache().      """ @@ -56,7 +61,7 @@ def cmp(f1, f2, shallow=True):      if outcome is None:          outcome = _do_cmp(f1, f2)          if len(_cache) > 100:      # limit the maximum size of the cache -            _cache.clear() +            clear_cache()          _cache[f1, f2, s1, s2] = outcome      return outcome  | 
