`glob.glob()` currently calls itself recursively to build a list of matches of the dirname part of the pattern and then filters by the basename part. This is effectively BFS. ``glob.glob('*/*/*/*/*/foo')`` will build a huge list of all directories 5 levels deep even if only a handful of them contain a ``foo`` entry. A generator-based recusion would never have to store these list at once by implementing DFS. This patch converts the `glob` function to an `iglob` recursive generator . `glob()` now just returns ``list(iglob(pattern))``. I also cleaned up the code a bit (reduced duplicate `has_magic()` checks and created a second `glob0` helper func so that the main loop need not be duplicated). This patch assumes patch 941486 adding `os.path.lexists()` was applied; if not the lexists calls will have to be adjasted. Tests and docs patches included.
Logged In: YES user_id=36166 Refreshed against current trunk (2.4a2+ 2004-08-20). It's a forward patch -p0, at dist/src. Again, it assumes patch 941486 (glob-pathfix.diff version) had been applied; if not s/lexists/exists/g but then neither version of 941486 will apply cleanly.