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

Peter Hansen peter at engcorp.com
Sat Aug 10 17:24:24 CEST 2002


Steven Atkinson wrote:
> [...]
> Ran again. Same results. Took out all IO from the Python script and ran it
> alone :15. Wow! Took the IO out of Ruby: :13. Humm. Put the IO back in both
> and ran in parrellel. Python :18, Ruby :14. Other runs would have different
> times, but Ruby would generally finish a tad faster. Tried to put the code
> back as orignally designed and could never get back to 2-3 minutes.

I think unless you find evidence to the contrary you'd best assume you
had something in the original code which was slowing it down but which
you forgot to add back in.  I've done the same often enough not to be
overly concerned when I can't reproduce my original results, unless I
actually took the time to carefully note each step as I went (which
is rare when I code-and-fix like this).

> profile, I can't say for sure what happened. My only "guess" is that Python
> may have been competing to get some sort of mutex/critical section protected
> resource/section of code that another program was also using. 

Not likely, I think.  As far as I know there is no such entity involved
in typical Python programs.  You'd have to work at it to add one.  I might
be wrong.

> I'll probably continue to try to find the culprit since unsolved mysteries 
> drive me crazy. (And in the end it'll probably turn out to be something 
> really stupid that I did!! :)

Save your effort and put it towards learning more Python.  You'll sleep
better knowing you didn't waste it on a goose chase. :)

-Peter



More information about the Python-list mailing list