1 \section{\module{statcache
} ---
2 An optimization of
\function{os.stat()
}}
4 \declaremodule{standard
}{statcache
}
5 \sectionauthor{Moshe Zadka
}{mzadka@geocities.com
}
6 \modulesynopsis{Stat files, and remember results.
}
8 The
\module{statcache
} module provides a simple optimization to
9 \function{os.stat()
}: remembering the values of previous invocations.
11 The
\module{statcache
} module defines the following functions:
13 \begin{funcdesc
}{stat
}{path
}
14 This is the main module entry-point.
15 Identical for
\function{os.stat()
}, except for remembering the result
16 for future invocations of the function.
19 The rest of the functions are used to clear the cache, or parts of
22 \begin{funcdesc
}{reset
}{}
23 Clear the cache: forget all results of previous
\function{stat()
}
27 \begin{funcdesc
}{forget
}{path
}
28 Forget the result of
\code{stat(
\var{path
})
}, if any.
31 \begin{funcdesc
}{forget_prefix
}{prefix
}
32 Forget all results of
\code{stat(
\var{path
})
} for
\var{path
} starting
36 \begin{funcdesc
}{forget_dir
}{prefix
}
37 Forget all results of
\code{stat(
\var{path
})
} for
\var{path
} a file in
38 the directory
\var{prefix
}, including
\code{stat(
\var{prefix
})
}.
41 \begin{funcdesc
}{forget_except_prefix
}{prefix
}
42 Similar to
\function{forget_prefix()
}, but for all
\var{path
} values
43 \emph{not
} starting with
\var{prefix
}.
49 >>> import os, statcache
50 >>> statcache.stat('.')
51 (
16893,
2049,
772,
18,
1000,
1000,
2048,
929609777,
929609777,
929609777)
53 (
16893,
2049,
772,
18,
1000,
1000,
2048,
929609777,
929609777,
929609777)