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

Matt Gerrans mgerrans at mindspring.com
Fri Aug 9 20:59:52 CEST 2002


Compiling the regular expression inside the walker is probably eating a good
number of cycles and doing a lot of repetitive work.

Anyway, in this case, you should probably use glob, not re.

Also, I have found that you get much nicer code when you create an object
for walking the path, and pass its walker method along with self to
os.path.walk() -- this is usually done by another method of the class, so
using the object is very clean and simple.

By the way, you can use the profile module to (profile.run()) to help you
find where CPU cycles are going -- it is very easy to use.





More information about the Python-list mailing list