Skip to content

Commit 4885f49

Browse files
committed
whatsnew: filecmp.clear_cache, and reword description of cache in docs.
1 parent 70e04f5 commit 4885f49

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Doc/library/filecmp.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ The :mod:`filecmp` module defines the following functions:
2828
portability and efficiency.
2929

3030
This function uses a cache for past comparisons and the results,
31-
with a cache invalidation mechanism relying on stale signatures
32-
or by explicitly calling :func:`clear_cache`.
31+
with cache entries invalidated if the :func:`os.stat` information for the
32+
file changes. The entire cache may be cleared using :func:`clear_cache`.
3333

3434

3535
.. function:: cmpfiles(dir1, dir2, common, shallow=True)
@@ -54,12 +54,12 @@ The :mod:`filecmp` module defines the following functions:
5454

5555
.. function:: clear_cache()
5656

57-
.. versionadded:: 3.4
58-
5957
Clear the filecmp cache. This may be useful if a file is compared so quickly
6058
after it is modified that it is within the mtime resolution of
6159
the underlying filesystem.
6260

61+
.. versionadded:: 3.4
62+
6363

6464
.. _dircmp-objects:
6565

Doc/whatsnew/3.4.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,17 @@ handling).
675675
(Contributed by R. David Murray in :issue:`18891`.)
676676

677677

678+
filecmp
679+
-------
680+
681+
A new :func:`~filecmp.clear_cache` function provides the ability to clear the
682+
:mod:`filecmp` comparison cache, which uses :func:`os.stat` information to
683+
determine if the file has changed since the last compare. This can be used,
684+
for example, if the file might have been changed and re-checked in less time
685+
than the resolution of a particular filesystem's file modification time field.
686+
(Contributed by Mark Levitt in :issue:`18149`.)
687+
688+
678689
functools
679690
---------
680691

Lib/filecmp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def cmp(f1, f2, shallow=True):
4343
True if the files are the same, False otherwise.
4444
4545
This function uses a cache for past comparisons and the results,
46-
with a cache invalidation mechanism relying on stale signatures
47-
or by explicitly calling clear_cache().
46+
with cache entries invalidated if their stat information
47+
changes. The cache may be cleared by calling clear_cache().
4848
4949
"""
5050

0 commit comments

Comments
 (0)