I am looking for a way to iterate through a directory containing 100,000’s of files. Using os.listdir is TERRIBLY slow because this function first takes in the path list from the whole specified path.
What are the fastest options?
NOTE: whoever downvoted has never faced this situation for sure.
This other question was referred to in comments as a duplicate:
List files in a folder as a stream to begin process immediately
…But I found the example to be semi not working. Here is the fixed version that works for me: