On Mon, 16 Sep 2013 15:48:54 -0400, Brett Cannon <br...@python.org> wrote: > On Mon, Sep 16, 2013 at 3:45 PM, Antoine Pitrou <solip...@pitrou.net> wrote: > > So I would like to propose the following API change: > > > > - Path.stat() (and stat-accessing methods such as get_mtime()...) > > returns an uncached stat object by default > > > > - Path.cache_stat() can be called to return the stat() *and* cache it > > for future use, such that any future call to stat(), cache_stat() or > > a stat-accessing function reuses that cached stat > > > > In other words, only if you use cache_stat() at least once is the > > stat() value cached and reused by the Path object. > > (also, it's a per-Path decision) > > > > Any reason why stat() can't get a keyword-only cached=True argument > instead? Or have stat() never cache() but stat_cache() always so that > people can choose if they want fresh or cached based on API and not whether > some library happened to make a decision for them?
Well, we tend to avoid single boolean arguments in favor of differently named functions. But here is an alternate API: expose the state by having a 'cache_stat' attribute of the Path that is 'False' by default but can be set 'True'. It could also (or only?) be set via an optional constructor argument. --David _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com