6.5 statcache -- An optimization of os.stat()

Python 2.4

6.5 statcache -- An optimization of os.stat()

The statcache module provides a simple optimization to os.stat(): remembering the values of previous invocations.

The statcache module defines the following functions:

This is the main module entry-point. Identical for os.stat(), except for remembering the result for future invocations of the function.

The rest of the functions are used to clear the cache, or parts of it.

Clear the cache: forget all results of previous stat() calls.

Forget the result of stat(path), if any.

Forget all results of stat(path) for path starting with prefix.

Forget all results of stat(path) for path a file in the directory prefix, including stat(prefix).

Similar to forget_prefix(), but for all path values not starting with prefix.

Example:

>>> import os, statcache
>>> statcache.stat('.')
(16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
>>> os.stat('.')
(16893, 2049, 772, 18, 1000, 1000, 2048, 929609777, 929609777, 929609777)
See About this document... for information on suggesting changes.