Hi, 2014-07-20 18:50 GMT+02:00 Antoine Pitrou <antoine at python.org>: > Have you tried modifying importlib's _bootstrap.py to use scandir() instead > of listdir() + stat()? IMO the current os.scandir() API does not fit importlib requirements. importlib usually wants fresh data, whereas DirEntry cache cannot be invalidated. It's probably possible to cache some os.stat() result in importlib, but it looks like it requires a non trivial refactoring of the code. I don't know importlib enough to suggest how to change it. There are many open isssues related to stat() in importlib, I found these ones: http://bugs.python.org/issue14604 http://bugs.python.org/issue14067 http://bugs.python.org/issue19216 Closed issues: http://bugs.python.org/issue17330 http://bugs.python.org/issue18810 By the way, DirEntry constructor is not documented in the PEP. Should we document it? It might be a way to "invalidate the cache": entry = DirEntry(os.path.dirname(entry.path), entry.name) Maybe it is an abuse of the API. A clear_cache() method would be less ugly :-) But maybe Ben Hoyt does not want to promote keeping DirEntry for a long time? Another question: should we expose DirEntry type directly in the os namespace? (os.DirEntry) Victor
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