The statcache module, shown in Example 14-15, contains a function that returns information about files. Its an extension of the os.stat function in that it keeps a cache with recently collected information.
File: statcache-example-1.py import statcache import os, stat, time now = time.time() for i in range(1000): st = os.stat("samples/sample.txt") print "os.stat", "=>", time.time() - now now = time.time() for i in range(1000): st = statcache.stat("samples/sample.txt") print "statcache.stat", "=>", time.time() - now print "mode", "=>", oct(stat.S_IMODE(st[stat.ST_MODE])) print "size", "=>", st[stat.ST_SIZE] print "last modified", "=>", time.ctime(st[stat.ST_MTIME]) os.stat => 0.371000051498 statcache.stat => 0.0199999809265 mode => 0666 size => 305 last modified => Sun Oct 10 18:39:37 1999
Core Modules
More Standard Modules
Threads and Processes
Data Representation
File Formats
Mail and News Message Processing
Network Protocols
Internationalization
Multimedia Modules
Data Storage
Tools and Utilities
Platform-Specific Modules
Implementation Support Modules
Other Modules