os.walk vs os.scandir, which is faster?
Working on a duplicate file finding package https://pypi.org/project/dupliCat/ and wanted to speed things up a little bit. So according to this PEP https://peps.python.org/pep-0471/ scandir is faster than os.walk, I currently use python 3.10. I wrote a recursive function with os.scandir to traverse a directory path, benchmarked both the function and os.walk using the timeit module to see which one's faster but surprisingly, os.walk seems to be faster, idk whether it has been optimized to run faster in 3.10 or it's something else. What seems to be my main concern is that Idk how to benchmark the two functions in fetching all files in the directory. Should it be the time taken to get all the files as a list/tuple or the time taken for the functions to run. The recursive scantree function I wrote yields each file it comes across.