blob: 765284916040a04ffa42964be4135efe4591fdba [file] [log] [blame]
Fred Drake64bc94e1999-06-17 15:11:35 +00001\section{\module{statcache} ---
2 An optimization of \function{os.stat()}}
3
4\declaremodule{standard}{statcache}
5\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
6\modulesynopsis{Stat files, and remember results.}
7
8The \module{statcache} module provides a simple optimization to
9\function{os.stat()}: remembering the values of previous invocations.
10
11The \module{statcache} module defines the following functions:
12
13\begin{funcdesc}{stat}{path}
14This is the main module entry-point.
15Identical for \function{os.stat()}, except for remembering the result
16for future invocations of the function.
17\end{funcdesc}
18
19The rest of the functions are used to clear the cache, or parts of
20it.
21
22\begin{funcdesc}{reset}{}
Fred Drake173ba5e1999-06-17 17:09:23 +000023Clear the cache: forget all results of previous \function{stat()}
24calls.
Fred Drake64bc94e1999-06-17 15:11:35 +000025\end{funcdesc}
26
27\begin{funcdesc}{forget}{path}
28Forget the result of \code{stat(\var{path})}, if any.
29\end{funcdesc}
30
31\begin{funcdesc}{forget_prefix}{prefix}
32Forget all results of \code{stat(\var{path})} for \var{path} starting
33with \var{prefix}.
34\end{funcdesc}
35
36\begin{funcdesc}{forget_dir}{prefix}
Fred Drake173ba5e1999-06-17 17:09:23 +000037Forget all results of \code{stat(\var{path})} for \var{path} a file in
Fred Drake64bc94e1999-06-17 15:11:35 +000038the directory \var{prefix}, including \code{stat(\var{prefix})}.
39\end{funcdesc}
40
41\begin{funcdesc}{forget_except_prefix}{prefix}
Fred Drake173ba5e1999-06-17 17:09:23 +000042Similar to \function{forget_prefix()}, but for all \var{path} values
Fred Drake64bc94e1999-06-17 15:11:35 +000043\emph{not} starting with \var{prefix}.
44\end{funcdesc}
45
46Example:
47
48\begin{verbatim}
49>>> import os, statcache
50>>> statcache.stat('.')
51(16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
52>>> os.stat('.')
53(16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
54\end{verbatim}