[Patches] optimizing posixpath.walk

Guido van Rossum guido@python.org
Mon, 28 Feb 2000 09:28:46 -0500


> the posixpath.walk function contains the following code:
> 
>               if isdir(name) and not islink(name):
> 
> This is, of course, very inefficient: it does os.stat on the same file
> twice directly after each other. So I changed this code to:
> 
>               st = os.lstat(name)
>               if stat.S_ISDIR(st[stat.ST_MODE]):
> 
> Must be much faster... minor context diff attached.

You're right -- although on my system the difference is in the noise,
I agree that it should be done this way.

You may consider patching the corresponding code in ntpath.py,
macpath.py and dospath.py as well.

> I sent those two patches in two different mails because of
> the different nature of those patches: you might want to
> refuse the former and accept the latter or vica versa.

Which two?  If you refer to your append() patches, I'm glad you put
them in separate mails!

--Guido van Rossum (home page: http://www.python.org/~guido/)