<div dir="ltr"><div><br></div>We can get a greater speed up for walkdir() without resorting to<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

caching, too. Some operating systems and file system report the file<br>
type in the dirent struct that is returned by readdir(). This reduces<br>
the number of stat calls to zero.<br></blockquote><div><br></div><div style>Yes, definitely. This is exactly what my os.walk() replacement, "Betterwalk", does:</div><div style><a href="https://github.com/benhoyt/betterwalk#readme">https://github.com/benhoyt/betterwalk#readme</a><br>
</div><div style><br></div><div style>On Windows you get *all* stat information from iterating the directory entries (FindFirstFile etc). And on Linux most of the time you get enough for os.walk() not to need an extra stat (though it does depend on the file system).</div>
<div style><br></div><div style>I still hope to clean up Betterwalk and make a C version so we can use it in the standard library. In many cases it speeds up os.walk() by several times, even an order of magnitude in some cases. I intend for it to be a drop-in replacement for os.walk(), just faster.</div>
<div style><br></div><div style>-Ben</div><div style><br></div></div></div></div>