[issue26032] Use scandir() to speed up pathlib globbing
Serhiy Storchaka
report at bugs.python.org
Mon Jan 11 07:20:21 EST 2016
Serhiy Storchaka added the comment:
Proposed minimal patch implements globbing in pathlib using os.scandir(). Here are results of microbenchmarks:
$ ./python -m timeit -s "from pathlib import Path; p = Path()" -- "list(p.glob('**/*'))"
Unpatched: 598 msec per loop
Patched: 372 msec per loop
$ ./python -m timeit -s "from pathlib import Path; p = Path('/usr/')" -- "list(p.glob('lib*/**/*'))"
Unpatched: 1.33 sec per loop
Patched: 804 msec per loop
$ ./python -m timeit -s "from pathlib import Path; p = Path('/usr/')" -- "list(p.glob('lib*/**/'))"
Unpatched: 750 msec per loop
Patched: 180 msec per loop
See msg257954 in issue25596 for comparison with the glob module.
----------
assignee: -> serhiy.storchaka
keywords: +patch
stage: -> patch review
Added file: http://bugs.python.org/file41577/pathlib_glob_scandir.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26032>
_______________________________________
More information about the Python-bugs-list
mailing list