Re: scandir slower than listdir

2017-07-20 Thread Tim Delaney
On 20 July 2017 at 21:43, Skip Montanaro wrote: > scandir returns an iterator of DirEntry objects which contain more > > information than the mere name. > > > > As I recall, the motivation for scandir was to avoid subsequent system > calls, so it will be slower than listdir the way you've tested

Re: scandir slower than listdir

2017-07-20 Thread Steve D'Aprano
On Thu, 20 Jul 2017 03:33 pm, Torsten Bronger wrote: > Hallöchen! > > With a 24,000 files directory on an SSD running Ubuntu, > > #!/usr/bin/python3 > > import os, time > > > start = time.time() > list(os.listdir("/home/bronger/.saves")) > print("listdir:", time.time() - s

Re: scandir slower than listdir

2017-07-20 Thread Skip Montanaro
scandir returns an iterator of DirEntry objects which contain more > information than the mere name. > As I recall, the motivation for scandir was to avoid subsequent system calls, so it will be slower than listdir the way you've tested it. If you add in the cost of fetching the other bits Terry m

Re: scandir slower than listdir

2017-07-19 Thread Terry Reedy
On 7/20/2017 1:33 AM, Torsten Bronger wrote: Hallöchen! With a 24,000 files directory on an SSD running Ubuntu, #!/usr/bin/python3 import os, time start = time.time() list(os.listdir("/home/bronger/.saves")) listdir returns a list of na print("listdir:", time.tim

scandir slower than listdir

2017-07-19 Thread Torsten Bronger
Hallöchen! With a 24,000 files directory on an SSD running Ubuntu, #!/usr/bin/python3 import os, time start = time.time() list(os.listdir("/home/bronger/.saves")) print("listdir:", time.time() - start) start = time.time() list(os.scandir("/home/bronger/.saves"))