annotate Doc/lib/libcmp.tex @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents 4b51d069be35
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{cmp} ---
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 File comparisons}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{cmp}
15467
d7864345b1c8 Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents: 11414
diff changeset
5 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 \modulesynopsis{Compare files very efficiently.}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7
16253
4b51d069be35 Removed references to Python 1.5.3; that was a "tentative" number I used
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
8 \deprecated{1.6}{Use the \refmodule{filecmp} module instead.}
11414
c8155d05d9ca Added deprecation notes, in case anyone decides to read these anyway.
Fred Drake <fdrake@acm.org>
parents: 10996
diff changeset
9
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 The \module{cmp} module defines a function to compare files, taking all
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11 sort of short-cuts to make it a highly efficient operation.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 The \module{cmp} module defines the following function:
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 \begin{funcdesc}{cmp}{f1, f2}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16 Compare two files given as names. The following tricks are used to
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 optimize the comparisons:
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 \begin{itemize}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 \item Files with identical type, size and mtime are assumed equal.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 \item Files with different type or size are never equal.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22 \item The module only compares files it already compared if their
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 signature (type, size and mtime) changed.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24 \item No external programs are called.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 \end{itemize}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 Example:
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 \begin{verbatim}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 >>> import cmp
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 >>> cmp.cmp('libundoc.tex', 'libundoc.tex')
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33 1
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 >>> cmp.cmp('libundoc.tex', 'lib.tex')
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 0
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 \end{verbatim}