Python 2.5.1 broken os.stat module

"Martin v. Löwis" martin at
Sat Jun 2 12:30:19 CEST 2007

> File Name       : P:\sw\Python\Lib\cgi.pyc
> python_access_ts: 05/31/2007  07:17 PM
> win_access_ts   : 05/31/2007  06:35 PM
> File Name       : P:\sw\Python\Lib\code.pyc
> python_access_ts: 05/30/2007  07:59 PM
> win_access_ts   : 05/30/2007  07:22 PM

I have analyzed these cases in more detail, and found
that Windows (dir and Explorer) indeed reports incorrect
last-access times. This is documented in

In essence, there are two places where the last-access
time is stored: In the file itself, and in the directory.
While the stamp in the file is constantly updated, the
stamp in the directory is only updated if the difference
exceeds one hour. This is done for performance reasons.

Python 2.5 reports the true last access time, whereas
dir, Explorer, and Python 2.4 report an access time
that isn't quite the *last* access time.

To see this for yourself, you can open a file,
and watch the last-access time as reported by Windows
not change, whereas Python reports a recent access
(if the time stamp changes indeed, wait a few minutes,
and access the file again - if the file hasn't been
accessed for more than one hour, the first access
will always update the time stamp right away).


More information about the Python-list mailing list