Using iterative filesystem walk instead of recursive

Considering we have multiple shutil functions relying on os.DirEntry objects, I still think the best option would be to use a scantree function, even if this were private to begin with (i.e. _scantree). This keeps us closer to the existing implementation and using Path objects is higher-level, slower, and introduces pathlib into shutil. This feels almost like introducing pathlib into os.path itself (okay not quite that bad, but close).

The Path.fwalk PR looks great to me though, and I’m not completely against using it. scantree will need some more work in order to be ready.

The only other function from shutil that uses os.DirEntry is copytree(). Initially I thought it could be implemented atop a walk() function/method, but now I’m not so sure (hence deleting my above post in shame!). If it’s not possible to implement copytree() atop walk(), then I concede that a new _scantree() function might be a better idea.

A post was split to a new topic: Path functions confined to one file system