
Guido van Rossum wrote:
I wonder if stat() caching shouldn't be made an orthogonal optional feature of Path objects somehow; it keeps coming back as useful in various cases even though we don't want to enable it by default.
Maybe path.stat() could return a PathWithStat object that inherits from Path and can do everything that a Path can do, but also contains cached stat info and has a suitable set of attributes for accessing it. This would make it clear at what point in time the info is valid for, i.e. the moment you called stat(). It would also provide an obvious way to refresh the info: calling path_with_stat.stat() would give you a new PathWithStat containing updated info. Things like scandir could then return pre-populated PathWithStat objects. -- Greg