annotate Doc/lib/libstatcache.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 3803af9d8796
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{statcache} ---
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 An optimization of \function{os.stat()}}
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}{statcache}
15467
d7864345b1c8 Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents: 11004
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{Stat files, and remember results.}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7
20840
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
8
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
9 \deprecated{2.2}{Use \function{\refmodule{os}.stat()} directly instead
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
10 of using the cache; the cache introduces a very high level of
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
11 fragility in applications using it and complicates application code
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
12 with the addition of cache management support.}
3803af9d8796 Add deprecation notice to statcache.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
13
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14 The \module{statcache} module provides a simple optimization to
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 \function{os.stat()}: remembering the values of previous invocations.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 The \module{statcache} module defines the following functions:
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{funcdesc}{stat}{path}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 This is the main module entry-point.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 Identical for \function{os.stat()}, except for remembering the result
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22 for future invocations of the function.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 The rest of the functions are used to clear the cache, or parts of
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 it.
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 \begin{funcdesc}{reset}{}
11004
8c114ede0568 Minor markup nits.
Fred Drake <fdrake@acm.org>
parents: 10996
diff changeset
29 Clear the cache: forget all results of previous \function{stat()}
8c114ede0568 Minor markup nits.
Fred Drake <fdrake@acm.org>
parents: 10996
diff changeset
30 calls.
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33 \begin{funcdesc}{forget}{path}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 Forget the result of \code{stat(\var{path})}, if any.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 \begin{funcdesc}{forget_prefix}{prefix}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 Forget all results of \code{stat(\var{path})} for \var{path} starting
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39 with \var{prefix}.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 \begin{funcdesc}{forget_dir}{prefix}
11004
8c114ede0568 Minor markup nits.
Fred Drake <fdrake@acm.org>
parents: 10996
diff changeset
43 Forget all results of \code{stat(\var{path})} for \var{path} a file in
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
44 the directory \var{prefix}, including \code{stat(\var{prefix})}.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
45 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
46
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47 \begin{funcdesc}{forget_except_prefix}{prefix}
11004
8c114ede0568 Minor markup nits.
Fred Drake <fdrake@acm.org>
parents: 10996
diff changeset
48 Similar to \function{forget_prefix()}, but for all \var{path} values
10996
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
49 \emph{not} starting with \var{prefix}.
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 \end{funcdesc}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 Example:
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
54 \begin{verbatim}
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
55 >>> import os, statcache
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
56 >>> statcache.stat('.')
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
57 (16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
58 >>> os.stat('.')
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
59 (16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
84ab14d85763 New module documentation sections from Moshe Zadka <moshez@math.huji.ac.il>!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
60 \end{verbatim}