blob: 489efee96252452f0999b166d83f19b195cc896c [file] [log] [blame]
Fred Drake64bc94e1999-06-17 15:11:35 +00001\section{\module{cmp} ---
2 File comparisons}
3
4\declaremodule{standard}{cmp}
Fred Drake57657bc2000-12-01 15:25:23 +00005\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
Fred Drake64bc94e1999-06-17 15:11:35 +00006\modulesynopsis{Compare files very efficiently.}
7
Fred Drake29052482001-01-25 17:29:18 +00008\deprecated{1.6}{Use the \refmodule{filecmp} module instead.}
Fred Drake7eaf6821999-10-26 16:31:51 +00009
Fred Drake64bc94e1999-06-17 15:11:35 +000010The \module{cmp} module defines a function to compare files, taking all
11sort of short-cuts to make it a highly efficient operation.
12
13The \module{cmp} module defines the following function:
14
15\begin{funcdesc}{cmp}{f1, f2}
16Compare two files given as names. The following tricks are used to
17optimize 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
28Example:
29
30\begin{verbatim}
31>>> import cmp
32>>> cmp.cmp('libundoc.tex', 'libundoc.tex')
331
34>>> cmp.cmp('libundoc.tex', 'lib.tex')
350
36\end{verbatim}