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 | |
| 8 | The \module{cmp} module defines a function to compare files, taking all |
| 9 | sort of short-cuts to make it a highly efficient operation. |
| 10 | |
| 11 | The \module{cmp} module defines the following function: |
| 12 | |
| 13 | \begin{funcdesc}{cmp}{f1, f2} |
| 14 | Compare two files given as names. The following tricks are used to |
| 15 | optimize the comparisons: |
| 16 | |
| 17 | \begin{itemize} |
| 18 | \item Files with identical type, size and mtime are assumed equal. |
| 19 | \item Files with different type or size are never equal. |
| 20 | \item The module only compares files it already compared if their |
| 21 | signature (type, size and mtime) changed. |
| 22 | \item No external programs are called. |
| 23 | \end{itemize} |
| 24 | \end{funcdesc} |
| 25 | |
| 26 | Example: |
| 27 | |
| 28 | \begin{verbatim} |
| 29 | >>> import cmp |
| 30 | >>> cmp.cmp('libundoc.tex', 'libundoc.tex') |
| 31 | 1 |
| 32 | >>> cmp.cmp('libundoc.tex', 'lib.tex') |
| 33 | 0 |
| 34 | \end{verbatim} |