[Python-Dev] Re: os.path.walk() lacks 'depth first' option

Tim Peters tim@zope.com
Fri, 25 Apr 2003 17:21:28 -0400

[andrew cooke]
> For the record - the version I posted (with breadth-first as an option)
> wasn't reliable (it runs out of stack space on reasonable directory
> structures).

Apart from that, did you have a use case for breadth-first directory
traversal?  Because it's clumsier, you usually find BFS only used on search
trees that are too deep/expensive to traverse exhaustively (e.g., a tree of
chess moves), or that have infinite paths (so that DFS can't terminate even
in theory).  Directory trees aren't usually <wink> of that nature.