I was wondering which method was faster to iterate through files in #python and find all files of a specific extension.

So I tried glob, pathlib, os.walk, and a listdir + a recursive function.

Here's how long it takes (in second), for different sizes of file systems.

os.walk is the fastest method
1 / 2
Post image
Post image

Comments