Fred Drake | 64bc94e | 1999-06-17 15:11:35 +0000 | [diff] [blame] | 1 | \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 Drake | 7eaf682 | 1999-10-26 16:31:51 +0000 | [diff] [blame] | 8 | % XXX check version number before release! |
| 9 | \deprecated{1.5.3}{Use the \module{filecmp} module instead.} |
| 10 | |
Fred Drake | 64bc94e | 1999-06-17 15:11:35 +0000 | [diff] [blame] | 11 | The \module{cmp} module defines a function to compare files, taking all |
| 12 | sort of short-cuts to make it a highly efficient operation. |
| 13 | |
| 14 | The \module{cmp} module defines the following function: |
| 15 | |
| 16 | \begin{funcdesc}{cmp}{f1, f2} |
| 17 | Compare two files given as names. The following tricks are used to |
| 18 | optimize 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 | |
| 29 | Example: |
| 30 | |
| 31 | \begin{verbatim} |
| 32 | >>> import cmp |
| 33 | >>> cmp.cmp('libundoc.tex', 'libundoc.tex') |
| 34 | 1 |
| 35 | >>> cmp.cmp('libundoc.tex', 'lib.tex') |
| 36 | 0 |
| 37 | \end{verbatim} |