blob: 4f81b3c3281dd825860f9d2f2f380026311944f6 [file] [log] [blame]
Fred Drake64bc94e1999-06-17 15:11:35 +00001\section{\module{cmp} ---
2 File comparisons}
3
4\declaremodule{standard}{cmp}
5\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
6\modulesynopsis{Compare files very efficiently.}
7
Fred Drake7eaf6821999-10-26 16:31:51 +00008% XXX check version number before release!
9\deprecated{1.5.3}{Use the \module{filecmp} module instead.}
10
Fred Drake64bc94e1999-06-17 15:11:35 +000011The \module{cmp} module defines a function to compare files, taking all
12sort of short-cuts to make it a highly efficient operation.
13
14The \module{cmp} module defines the following function:
15
16\begin{funcdesc}{cmp}{f1, f2}
17Compare two files given as names. The following tricks are used to
18optimize the comparisons:
19
20\begin{itemize}
21 \item Files with identical type, size and mtime are assumed equal.
22 \item Files with different type or size are never equal.
23 \item The module only compares files it already compared if their
24 signature (type, size and mtime) changed.
25 \item No external programs are called.
26\end{itemize}
27\end{funcdesc}
28
29Example:
30
31\begin{verbatim}
32>>> import cmp
33>>> cmp.cmp('libundoc.tex', 'libundoc.tex')
341
35>>> cmp.cmp('libundoc.tex', 'lib.tex')
360
37\end{verbatim}