Is there a `pathlib` equivalent of `os.scandir()`?

Thanks for mentioning Path.iterdir. When I look at the implementation it turns out that it’s a generator of calls to os.listdir. Hence, it must be just as slow as its os-equivalent.

Note that the entire argument is about os.scandir being performant, while os.listdir, os.walk, and likely Path.walk, is not. I’d like to avoid that I – and other people – earn a speed penalty only because they want to be purist and blindly switch to what pathlib offers.

For everyone’s convenience, the motivation and history of os.scandir is well explained at, e.g.