Line | |
---|
1 | \section{\module{cmp} ---
|
---|
2 | File comparisons}
|
---|
3 |
|
---|
4 | \declaremodule{standard}{cmp}
|
---|
5 | \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
|
---|
6 | \modulesynopsis{Compare files very efficiently.}
|
---|
7 |
|
---|
8 | \deprecated{1.6}{Use the \refmodule{filecmp} module instead.}
|
---|
9 |
|
---|
10 | The \module{cmp} module defines a function to compare files, taking all
|
---|
11 | sort of short-cuts to make it a highly efficient operation.
|
---|
12 |
|
---|
13 | The \module{cmp} module defines the following function:
|
---|
14 |
|
---|
15 | \begin{funcdesc}{cmp}{f1, f2}
|
---|
16 | Compare two files given as names. The following tricks are used to
|
---|
17 | optimize the comparisons:
|
---|
18 |
|
---|
19 | \begin{itemize}
|
---|
20 | \item Files with identical type, size and mtime are assumed equal.
|
---|
21 | \item Files with different type or size are never equal.
|
---|
22 | \item The module only compares files it already compared if their
|
---|
23 | signature (type, size and mtime) changed.
|
---|
24 | \item No external programs are called.
|
---|
25 | \end{itemize}
|
---|
26 | \end{funcdesc}
|
---|
27 |
|
---|
28 | Example:
|
---|
29 |
|
---|
30 | \begin{verbatim}
|
---|
31 | >>> import cmp
|
---|
32 | >>> cmp.cmp('libundoc.tex', 'libundoc.tex')
|
---|
33 | 1
|
---|
34 | >>> cmp.cmp('libundoc.tex', 'lib.tex')
|
---|
35 | 0
|
---|
36 | \end{verbatim}
|
---|
Note:
See
TracBrowser
for help on using the repository browser.