Python vs. Ruby (and os.path.walk)
opengeometry at yahoo.ca
Fri Aug 9 08:51:23 CEST 2002
On Fri, Aug 09, 2002 at 04:04:39AM +0000, Steven Atkinson wrote:
> 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.
For crying out loud,
find -type f \( -name '*_[ip].c' -o -name '*.th[il]' \) | xargs rm
> 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.
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin
More information about the Python-list