scandir slower than listdir

Skip Montanaro skip.montanaro at gmail.com
Thu Jul 20 07:43:44 EDT 2017


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 mentioned, I suspect your
relative timing will change.

Skip



More information about the Python-list mailing list