[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)

Victor Stinner victor.stinner at gmail.com
Tue Jul 8 17:13:08 CEST 2014


Hi,

2014-07-08 15:52 GMT+02:00 Ben Hoyt <benhoyt at gmail.com>:

After some very good python-dev feedback on my first version of PEP 471, I've updated the PEP to clarify a few things and added various "Rejected ideas" subsections. Here's a link to the new version (I've also copied the full text below):

Thanks, the new PEP looks better.

* Removed the "open issues" section, as the three open issues have either been included (fullname) or rejected (windowswildcard)

I remember a pending question on python-dev:

One known error in the PEP is that the "Notes" sections should be top-level sections, not be subheadings of "Examples". If someone would like to give me ("benhoyt") commit access to the peps repo, I can fix this and any other issues that come up.

Or just send me your new PEP ;-)

Notes on caching ----------------

The DirEntry objects are relatively dumb -- the name and fullname attributes are obviously always cached, and the isX and lstat methods cache their values (immediately on Windows via FindNextFile, and on first use on POSIX systems via a stat call) and never refetch from the system.

It is not clear to me which methods share the cache.

On UNIX, is_dir() and is_file() call os.stat(); whereas lstat() and is_symlink() call os.lstat().

If os.stat() says that the file is not a symlink, I guess that you can use os.stat() result for lstat() and is_symlink() methods?

In the worst case, if the path is a symlink, would it be possible that os.stat() and os.lstat() become "inconsistent" if the symlink is modified between the two calls? If yes, I don't think that it's an issue, it's just good to know it.

For symlinks, readdir() returns the status of the linked file or of the symlink?

Victor



More information about the Python-Dev mailing list