[Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

Ben Hoyt benhoyt at gmail.com
Tue Jul 15 14:05:55 CEST 2014


> Sorry, I don't remember who but someone proposed to add the follow_symlinks
> parameter in scandir()  directly. If the parameter is added to methods,
> there is no such issue.

Yeah, I think having the DirEntry methods do different things
depending on how scandir() was called is a really bad idea. It seems
you're agreeing with this?

> Again: remove any garantee about the cache in the definitions of methods,
> instead copy the doc from os.path and os. Add a global remark saying that
> most methods don't need any syscall in general, except for symlinks (with
> follow_symlinks=True).

I'm not sure I follow this -- surely it *has* to be documented that
the values of DirEntry.is_X() and DirEntry.stat() are cached per
entry, in contrast to os.path.isX()/os.stat()?

I don't mind a global remark about not needing syscalls, but I do
think it makes sense to make it explicit -- that is_X() almost never
need syscalls, whereas stat() does only on POSIX but is free on
Windows (except for symlinks).

-Ben


More information about the Python-Dev mailing list