[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Thu Jul 10 15:58:57 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 ]
On 10 Jul 2014 03:39, "Victor Stinner" <victor.stinner at gmail.com> wrote:
2014-07-10 9:04 GMT+02:00 Paul Moore <p.f.moore at gmail.com>: > As someone (Tim?) pointed out later in the thread, > FindFirstFile/FindNextFile doesn't follow symlinks by default (and nor > do the dirent entries on Unix). So whether or not it's "natural", the > "free" functionality provided by the OS is that of lstat, not that of > stat. Presumably because it's possible to build symlink-following code > on top of non-following code, but not the other way around. DirEntry methods will remain free (no syscall) for directories and regular files. One extra syscall will be needed only for symlinks, which are more rare than other file types (for example, you wrote " Windows typically makes little use of symlinks").
The info we want for scandir is that of the link itself. That makes it easy to implement things like the "followlinks" flag of os.walk. The far end of the link isn't relevant at this level.
The docs just need to be clear that DirEntry objects always match lstat(), never stat().
Cheers, Nick.
See my pseudo-code: https://mail.python.org/pipermail/python-dev/2014-July/135439.html On Windows, lstat and stat attributes will be filled directly in the constructor on Windows for regular files and directories. Victor
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140710/5ebbf34a/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 ]