[issue26032] Use scandir() to speed up pathlib globbing

STINNER Victor report at bugs.python.org
Wed Jan 6 18:03:57 EST 2016


STINNER Victor added the comment:

> As I recall, if the platform's DirEntry doesn't provide the cacheable attributes when first called, those attributes will be looked up (and cached) on first access.

scandir() is not magic. It simply provides info given by the OS: see readdir() on UNIX and FindFirstFile()/FindNextFile() on Windows.

DirEntry calls os.stat() if needed, but it caches the result.

DirEntry doc tries to explain when syscalls or required or not, depending on the requested information and the platform:
https://docs.python.org/dev/library/os.html#os.DirEntry

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26032>
_______________________________________


More information about the Python-bugs-list mailing list