on-internet
← Community

pathlib takes more time traversing directory recursively than os.walk()

Stack Overflow ·

I'm experimenting to determine if the pathlib module is an improvement over the os for directory traversal. To my surprise, I am getting better readings from the os module when compared to pathlib. Which is something I was not expecting. Is it because the os module is dumb enough to not care if the path string represents a file or a directory or a link etc.? So speed vs. better control? Perhaps I am not using pathlib the way it should be used for this. Here's the code: import os import sys import pathlib import time import pdb def TraverseDir(path=None, oswalk=None): if path is None: path = pa

Comments

Sign in or sign up to comment and upvote.

No comments yet.