Python Forum
why i don't like os.walk()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why i don't like os.walk()
#11
did you try pathlib?
FYI the following was corrected.
Quote:From: Guido van Rossum <gui...@python.org>
Mon, 11 Jan 2016 12:41:48 -0800

On Mon, Jan 11, 2016 at 10:57 AM, Gregory P. Smith <[email protected]> wrote:

> On Wed, Jan 6, 2016 at 3:05 PM Brendan Moloney <[email protected]> wrote:>>> Its important to keep in mind the main benefit of scandir is you don't>> have to do ANY stat call in many cases, because the directory listing>> provides some subset of this info. On Linux you can at least tell if a path>> is a file or directory. On windows there is much more info provided by the>> directory listing. Avoiding subsequent stat calls is also nice, but not>> nearly as important due to OS level caching.>>>> +1 - this was one of the two primary motivations behind scandir. Anything> trying to reimplement a filesystem tree walker without using scandir is> going to have sub-standard performance.>> If we ever offer anything with "find like functionality" related to> pathlib, it *needs* to be based on scandir. Anything else would just be> repeating the convenient but untrue limiting assumptions of os.listdir:> That the contents of a directory can be loaded into memory and that we> don't mind re-querying the OS for stat information that it already gave us> but we threw away as part of reading the directory.>

And we already have this in the form of pathlib's [r]glob() methods.
There's a patch to the glob module in http://bugs.python.org/issue25596 and
as soon as that's committed I hope that its author(s) will work on doing a
similar patch for pathlib's [r]glob (tracking this in
http://bugs.python.org/issue26032).

--
--Guido van Rossum (python.org/~guido)
Reply


Messages In This Thread
why i don't like os.walk() - by Skaperen - Jan-09-2018, 05:50 AM
RE: why i don't like os.walk() - by Larz60+ - Jan-09-2018, 06:35 AM
RE: why i don't like os.walk() - by Gribouillis - Jan-09-2018, 07:44 AM
RE: why i don't like os.walk() - by Skaperen - Jan-09-2018, 08:39 AM
RE: why i don't like os.walk() - by Gribouillis - Jan-09-2018, 08:48 AM
RE: why i don't like os.walk() - by DeaD_EyE - Jan-09-2018, 08:53 AM
RE: why i don't like os.walk() - by wavic - Jan-09-2018, 05:09 PM
RE: why i don't like os.walk() - by Gribouillis - Jan-09-2018, 05:18 PM
RE: why i don't like os.walk() - by Skaperen - Jan-10-2018, 03:26 AM
RE: why i don't like os.walk() - by Skaperen - Jan-10-2018, 04:44 AM
RE: why i don't like os.walk() - by Larz60+ - Jan-10-2018, 05:03 AM
RE: why i don't like os.walk() - by Gribouillis - Jan-10-2018, 05:12 AM
RE: why i don't like os.walk() - by Skaperen - Jan-10-2018, 05:54 AM
RE: why i don't like os.walk() - by Skaperen - Jan-10-2018, 07:01 AM
RE: why i don't like os.walk() - by Gribouillis - Jan-10-2018, 10:45 PM
RE: why i don't like os.walk() - by snippsat - Jan-10-2018, 11:59 PM
RE: why i don't like os.walk() - by Skaperen - Jan-11-2018, 01:37 AM
RE: why i don't like os.walk() - by Larz60+ - Jan-11-2018, 02:23 AM
RE: why i don't like os.walk() - by Skaperen - Jan-11-2018, 06:00 AM
RE: why i don't like os.walk() - by Gribouillis - Jan-11-2018, 07:07 AM
RE: why i don't like os.walk() - by Skaperen - Jan-11-2018, 08:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  examples using os.walk() Skaperen 12 7,196 Mar-22-2021, 05:56 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020