[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)
Victor Stinner victor.stinner at gmail.com
Tue Jul 8 21:55:59 CEST 2014
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le mardi 8 juillet 2014, Ben Hoyt <benhoyt at gmail.com> a écrit :
> It is not clear to me which methods share the cache. > > On UNIX, isdir() and isfile() call os.stat(); whereas lstat() and > issymlink() 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 issymlink() 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? I think you're misunderstanding isdir() and isfile(), as these don't actually call os.stat(). All DirEntry methods either call nothing or os.lstat() to get the stat info on the entry itself (not the destination of the symlink).
Oh. Extract of your PEP: "is_dir(): like os.path.isdir(), but much cheaper".
genericpath.isdir() and genericpath.isfile() use os.stat(), whereas posixpath.islink() uses os.lstat().
Is it a mistake in the PEP?
In light of this, I don't think what you're describing above is an issue.
I'm not saying that there is an issue, I'm just trying to understand.
Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140708/062870b1/attachment.html>
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]