1999-06-17 12:11:35 -03:00
|
|
|
\section{\module{cmp} ---
|
|
|
|
File comparisons}
|
|
|
|
|
|
|
|
\declaremodule{standard}{cmp}
|
2000-12-01 11:25:23 -04:00
|
|
|
\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
|
1999-06-17 12:11:35 -03:00
|
|
|
\modulesynopsis{Compare files very efficiently.}
|
|
|
|
|
2001-01-25 13:29:18 -04:00
|
|
|
\deprecated{1.6}{Use the \refmodule{filecmp} module instead.}
|
1999-10-26 13:31:51 -03:00
|
|
|
|
1999-06-17 12:11:35 -03:00
|
|
|
The \module{cmp} module defines a function to compare files, taking all
|
|
|
|
sort of short-cuts to make it a highly efficient operation.
|
|
|
|
|
|
|
|
The \module{cmp} module defines the following function:
|
|
|
|
|
|
|
|
\begin{funcdesc}{cmp}{f1, f2}
|
|
|
|
Compare two files given as names. The following tricks are used to
|
|
|
|
optimize the comparisons:
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
\item Files with identical type, size and mtime are assumed equal.
|
|
|
|
\item Files with different type or size are never equal.
|
|
|
|
\item The module only compares files it already compared if their
|
|
|
|
signature (type, size and mtime) changed.
|
|
|
|
\item No external programs are called.
|
|
|
|
\end{itemize}
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
>>> import cmp
|
|
|
|
>>> cmp.cmp('libundoc.tex', 'libundoc.tex')
|
|
|
|
1
|
|
|
|
>>> cmp.cmp('libundoc.tex', 'lib.tex')
|
|
|
|
0
|
|
|
|
\end{verbatim}
|