[Tutor] os.path.walk vs unix find command
Steve Willoughby
steve at alchemy.com
Sat Aug 16 05:17:49 CEST 2008
Kent Johnson wrote:
>> Is os.popen("find") faster or slower than os.path.walk to find file pattern
>> in the
The general answer to "is find faster than os.[path.]walk faster" is "it
depends." Find is optimized, compiled, and fast at what it does.
However, what it does is somewhat limited. If you want to descend a
filesystem doing anything complex along the way, it might be better to
walk it from inside Python (or Perl or whatever) than to hook find up to
other shell utilities or to create a pipe out from Python to find and
back again.
More information about the Tutor
mailing list