Author brian.curtin
Recipients brian.curtin, eli.bendersky, giampaolo.rodola, loewis, stutzbach, tim.golden
Date 2011-06-03.18:59:20
SpamBayes Score 2.22983e-12
Marked as misclassified No
Message-id <1307127562.65.0.465732341276.issue11583@psf.upfronthosting.co.za>
In-reply-to
Content
Attached is a patch that makes this about twice as fast for regular files and about 15 times faster for symbolic links and directories.

Not that this would be anyone's performance bottleneck, but it does make the time more of a constant due to the recursion and extra overhead when stat'ing symbolic paths. The numbers were tested with the patch on #12084 (new stat impl).


# The numbers were run before I hooked nt._isdir up through Lib/ntpath.py, so os.path.isdir is the old way.
# Regular file
>PCbuild\amd64\python.exe -m timeit -s "import nt" "nt._isdir('README')"
10000 loops, best of 3: 25 usec per loop

>PCbuild\amd64\python.exe -m timeit -s "import os" "os.path.isdir('README')"
10000 loops, best of 3: 43 usec per loop

# Regular directory

>PCbuild\amd64\python.exe -m timeit -s "import nt" "nt._isdir('Lib')"
10000 loops, best of 3: 24.3 usec per loop

>PCbuild\amd64\python.exe -m timeit -s "import os" "os.path.isdir('Lib')"
10000 loops, best of 3: 41.4 usec per loop

# testlink is a symbolically linked directory

>PCbuild\amd64\python.exe -m timeit -s "import nt" "nt._isdir('testlink')"
10000 loops, best of 3: 26.1 usec per loop

>PCbuild\amd64\python.exe -m timeit -s "import os" "os.path.isdir('testlink')"
1000 loops, best of 3: 415 usec per loop

# setup.py.link is a symbolic link

>PCbuild\amd64\python.exe -m timeit -s "import nt" "nt._isdir('setup.py.link')"
10000 loops, best of 3: 25.8 usec per loop

>PCbuild\amd64\python.exe -m timeit -s "import os" "os.path.isdir('setup.py.link')"
1000 loops, best of 3: 336 usec per loop
History
Date User Action Args
2011-06-03 18:59:22brian.curtinsetrecipients: + brian.curtin, loewis, giampaolo.rodola, tim.golden, stutzbach, eli.bendersky
2011-06-03 18:59:22brian.curtinsetmessageid: <1307127562.65.0.465732341276.issue11583@psf.upfronthosting.co.za>
2011-06-03 18:59:22brian.curtinlinkissue11583 messages
2011-06-03 18:59:21brian.curtincreate