[Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon May 13 15:13:03 CEST 2013


On Mon, May 13, 2013 at 10:25 PM, Ben Hoyt <benhoyt at gmail.com> wrote:

Okay, I've renamed my "BetterWalk" module to "scandir" and updated it as per our discussion:

https://github.com/benhoyt/scandir/#readme

Nice!

PERFORMANCE: On Windows I'm seeing that scandir.walk() on a large test tree (see benchmark.py) is 8-9 times faster than os.walk(), and on Linux it's 3-4 times faster. Yes, it is that much faster, and yes, those numbers are real. :-)

I'd to see the numbers for NFS or CIFS - stat() can be brutally slow over a network connection (that's why we added a caching mechanism to importlib).

Please critique away. At this stage it'd be most helpful to critique any API or performance-related issues rather than coding style or minor bugs, as I'm expecting the code itself will change quite a bit still.

I initially quite liked the idea of not offering any methods on DirEntry, only properties, to make it obvious that they don't touch the file system, but just report info from the scandir call. However, I think that it ends up reading strangely, and would be confusing relative to the os.path() APIs.

What you have now seems like a good, simple alternative.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list