Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 2a9b0a93091b9ef7350a94bb3d3f1c43725b7a8c authored by Georg Brandl on 05 March 2011, 13:54:19 UTC
Close 2.0 branch.
Tip revision: 2a9b0a9
libcmp.tex
\section{\module{cmp} ---
         File comparisons}

\declaremodule{standard}{cmp}
\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
\modulesynopsis{Compare files very efficiently.}

% XXX check version number before release!
\deprecated{1.5.3}{Use the \module{filecmp} module instead.}

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}
back to top