Ben Hoyt added the comment:

Thanks for the initial response and code review, Victor. I'll take a look and 
respond further in the next few days.

In the meantime, however, I'm definitely open to splitting scandir out into its 
own C file. This will mean a little refactoring (making some functions 
public/non-static).

Based on the numbers so far, I'm not so keen on implementing just the sys calls 
in C and the rest in Python. I already do basically this with ctypes in the 
scandir module, and it's slowish. I'll send proper numbers through soon, but 
here's what I remember from running benchmark.py on my Windows laptop with SSD 
drive:

ctypes version: os.walk() 9x faster with scandir
CPython 3.5 C version (debug): os.walk() 24x faster with scandir
CPython 3.5 C version (release): os.walk() 55x faster with scandir

So you do get a lot of speedup from just the ctypes version, but you get a lot 
more (55/9 = 6x more here) by using the all-C version. Again, these numbers are 
from memory -- I'll send exact ones later.

One of the problems is that creating the DirEntry objects and calling their 
methods is fairly expensive, and if this is all done in Python, you lose a lot. 
I believe scandir() would end up being slower than listdir() in many cases.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22524>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to