<p dir="ltr"><br>
On 1 May 2013 22:58, "Charles-François Natali" <<a href="mailto:cf.natali@gmail.com">cf.natali@gmail.com</a>> wrote:<br>
><br>
> > 3) Leave it up to performance critical code, such as the import<br>
> > machinery, or walkdirs that Nick mentioned, to do their own caching, and<br>
> > simplify the filepath API for the simple case.<br>
> ><br>
> > But one can still make life easier for code like that, by adding<br>
> > is_file() and friends on the stat result object as I suggested.<br>
><br>
> +1 from me.<br>
> PEP 428 goes in the right direction with a distinction between "pure"<br>
> path and "concrete" path. Pure path support syntactic operations,<br>
> whereas I would expect concrete paths to actually access the file<br>
> system. Having a method like restat() is a hint that something's<br>
> wrong, I'm convinced this will bite some people.<br>
><br>
> I'm also be in favor of having a wrapper class around os.stat() result<br>
> which would export utility methods such as is_file()/is_directory()<br>
> and owner/group, etc attributes.<br>
><br>
> That way, the default behavior would be correct, and this helper class<br>
> would make it easier for users like walkdir() to implement their own<br>
> caching.</p>
<p dir="ltr">Walkdir is deliberately built as a decoupled pipeline modelled on os.walk - the only way it can really benefit from caching without destroying the API is if the caching is built into the underlying path objects that are then passed through the pipeline stages.</p>

<p dir="ltr">However, I like the idea of a rich "stat" object, with "path.stat()" and "path.cached_stat()" accessors on the path objects.</p>
<p dir="ltr">Up to date data by default, easy caching for use cases that need it without needing to pass the stat data around separately.</p>
<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> As an added benefit, this would make path objects actually immutable,<br>
> which is always a good thing (simpler, and you get thread-safety for<br>
> free).<br>
> _______________________________________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="http://mail.python.org/mailman/listinfo/python-dev">http://mail.python.org/mailman/listinfo/python-dev</a><br>
> Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com">http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com</a><br>
</p>