[Python-ideas] BetterWalk, a better and faster os.walk() for Python

Ben Hoyt benhoyt at gmail.com
Mon Nov 26 09:19:55 CET 2012

>> There is one thing that is advantageous about creating an ideal enhanced
>> os.walk. People would only have to change the module walk is getting imported
>> from, no changes would have to be made anywhere else even if that code is
>> using features like the ability to modify dirnames (when topdown=True).
> Sure, there's a whole lot of existing code, and existing knowledge in people's
> heads, so, if it turns out to be easy, we might as well provide a drop-in
> replacement.

Yeah, that's the main reason that if nothing else comes of all this,
I'd still love to speed up os.walk() on Windows by 3x to 6x. Whether
or not iterdir_stat() or anything else is added to the stdlib.

> But if it's not, I'd be happy enough with something like, "You can use fts.walk
> as a faster replacement for os.walk if you don't modify dirnames. If you do need
> to modify dirnames, either stick with os.path, or rewrite your code around fts."

I'm afraid looking into fts is beyond the scope of the work I'd like
to do at the moment.

> I was just bringing up the point that, in your quest for mapping Python to C as
> thinly as possibly on POSIX, you're inherently making the mapping a little
> thicker on Windows. That isn't necessarily a problem—the same thing is true for
> much of the os module today, after all—just something to keep in mind.

Totally agreed.


More information about the Python-ideas mailing list