[Python-Dev] pathlib+os/shutil feedback
Sven R. Kunze
srkunze at mail.de
Mon Apr 11 16:39:19 EDT 2016
On 10.04.2016 16:51, Paul Moore wrote:
> 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.
I'd appreciate some guidance on this. Just let me know what I can do
since I don't know the processes of hacking CPython.
> """
> Path.rglob(pattern)
> 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.
Good point. The proposed docstring was just to illustrate the
functionality to the uninformed reader. People mostly trust the docs
without digging deeper but they should be accurate of course.
Best,
Sven
More information about the Python-Dev
mailing list