benhoyt/scandir — pull request #25 by abarnert (2014-06-21 05:04:27+00:00)
Title: Working fts implementation.

I'm not actually expecting this pull request to be accepted; look it over, comment on it, and reject it.

README.fts explains most of the details.

fts.py is a prototype wrapper around the `fts` function on linux and \*BSD (including OS X) that provides a similar, but different, API to `os.walk`. It requires `cffi` (which a real implementation wouldn't—and a real implementation would probably be a lot faster, too, as discussed in the readme).

It does not include an `os.walk` replacement, just the `fts` interface. The updated benchmark.py shows how easy/hard it is to switch from `os.walk` to `fts.FTS`.

I've also includes an (incomplete) simplified-fts interface built on top of both `fts` and `scandir`, which you can see in ftss.py. I think something like this would be worth adding to the stdlib (maybe as `pathlib.Path.walk`?). I'm sure it has some bugs, on top of being incomplete; it's just to demonstrate the idea I raised in the readme.