> 3) Leave it up to performance critical code, such as the import > machinery, or walkdirs that Nick mentioned, to do their own caching, and > simplify the filepath API for the simple case. > > But one can still make life easier for code like that, by adding > is_file() and friends on the stat result object as I suggested. +1 from me. PEP 428 goes in the right direction with a distinction between "pure" path and "concrete" path. Pure path support syntactic operations, whereas I would expect concrete paths to actually access the file system. Having a method like restat() is a hint that something's wrong, I'm convinced this will bite some people. I'm also be in favor of having a wrapper class around os.stat() result which would export utility methods such as is_file()/is_directory() and owner/group, etc attributes. That way, the default behavior would be correct, and this helper class would make it easier for users like walkdir() to implement their own caching. As an added benefit, this would make path objects actually immutable, which is always a good thing (simpler, and you get thread-safety for free).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4