[Python-Dev] pathlib+os/shutil feedback

Paul Moore p.f.moore at gmail.com
Sun Apr 10 10:51:05 EDT 2016

On 10 April 2016 at 15:07, Sven R. Kunze <srkunze at mail.de> wrote:
> If there's some agreement to change things with respect to those 5 points, I
> am willing to put some time into it.

In broad terms I agree with these points. Thanks for doing the
research. It would certainly be good to try to improve pathlib based
on this sort of feedback while it is still provisional.

One specific point - you say:

Walk down a given path; a wrapper for "os.scandir"/"os.listdir".

However, at least in 3.5, Path.rglob does *not* wrap scandir. There's
a difference in principle, in that scandir (DirEntry) objects cache
stat data, where pathlib does not. Whether that makes using scandir in
Path.rglob impossible, I don't know. Ideally I'd like to see pathlib
modified to use scandir (because otherwise there will always be people
saying "use os.walk rather than scandir, as it's faster) - or if it's
not possible to do so because of the difference in principle, then I'd
like to see a clear discussion of the issue in the docs, including the
recommended approach for people who want scandir performance *without*
having to abandon pathlib for lower level functions.


More information about the Python-Dev mailing list