Python vs. Ruby (and os.path.walk)

Steven Atkinson sja at san.rr.com
Fri Aug 9 06:04:39 CEST 2002


I'm trying to settle on Ruby or Python as my scripting language of choice.
There are some features of Ruby that I like, but I lean toward Python since
by day I'm a C++ programmer and Python seems more natural to me.
Unfortunately, in my first side by side test I discovered a _huge_
performance difference (at least for what I wanted to do). I need a simple
program that can clean out some tool generated source code. I'm recursively
searching 100's (probably close to or slightly over a 1000) directories
searching for certain file extensions (*_i.c, *_p.c,*.thi, *.thl) and then
removing them. The Ruby version runs in about 20-30 seconds. The Python
version takes 2-3 minutes! My feeling is that it's probably just the
os.path.walk library routine is slow (only on NT, haven't tried on Linux.
Maybe that's a good sanity check.). So before I dig into the code to
determine why it's so slow I'd like to know if others experience slowness
with Python overall, just the os.path.walk routine, only the NT version.

I'll probably need to do lots of directory searching in future scripts, so
I'd like that to be reasonably fast. Granted I could write my own extension,
or maybe call the Win32 functions directly since the code does not need to
be portable, but I'd rather not do that.

TIA







More information about the Python-list mailing list