Contributing os.scandir() to Python
benhoyt.com
benhoyt.com
* the joys of contributing to Python
* how time and labor intensive the process can be
* the complexities of dealing with multiple operating systems
* what it is like to be alternately helped or hindered by other developers
https://github.com/benhoyt/scandir/issues/22
(Source: It was my issue :) )
I was long using the project since it was named betterwalk and was very glad to see PEP 471 approved. Great work Ben.
(Now I just need to upgrade the project I use it in to 3.5)
Thanks again for all your efforts.
I think part of the issue (though I've not tested this yet) is that we're stat()-ing every single file anyway so with os cache considered, it really ends up not mattering anyway.
I thought the additional cost of the extra system calls (even if they were entirely cached in memory) would add up, but, it seems like something the scandir module is doing is just less efficient in general.
Devising some much simpler and more controllable tests (but still with our exact workload) and testing more though.
Also, not remotely hating on what you did here. I actually wrote/tested a very similar concept in python several years ago for the exact same reason. My C-skills (and mostly time resources) weren't really up to par to try to get it included in core. I mostly really want this to work as well as I think it should :)
I'll run some tests with your benchmark.py (and compare that to my benchmark script) and post some results.
Results are very similar/identical to what my tool said.
Interestingly, If I look at strace call graphs the scandir version spends basically an identical amount of time in getdents as the os version, but, the os version spends a bunch of time in stat calls too. It just seems like on my workload, that time is considerably less than I expected.
NFSv3 introduced READDIRPLUS in 1995: https://tools.ietf.org/html/rfc1813#section-3.3.17
FUSEv3 (the library) will have support for such a call. It is already in the git repository ( https://github.com/libfuse/libfuse/blob/master/include/fuse_... ) .
Sadly, there is still no syscall on linux to do a "readdirplus" (usually called xgetdents()).