Brian Curtin <br...@python.org> added the comment:

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

----------
keywords: +needs review, patch
stage: needs patch -> patch review
Added file: http://bugs.python.org/file22236/issue11583.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11583>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to