This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Use glob.glob() to implement pathlib.Path.glob()
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: barneygale
Priority: normal Keywords:

Created on 2021-05-13 05:35 by barneygale, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg393556 - (view) Author: Barney Gale (barneygale) * Date: 2021-05-13 05:35
I have a scratchy patch that replaces pathlib's globbing implementation with glob.glob(), which gained a `root_dir` argument in bpo-38144

Encouraging timings:

$ ./python -m timeit -s "from pathlib import Path; p = Path()" -- "list(p.glob('**/*'))"
Unpatched: 43.2 msec per loop
Patched:   4.37 msec per loop

$ ./python -m timeit -s "from pathlib import Path; p = Path('/usr/')" -- "list(p.glob('lib*/**/*'))"
Unpatched: 248 msec per loop
Patched:   56.8 msec per loop

$ ./python -m timeit -s "from pathlib import Path; p = Path('/usr/')" -- "list(p.glob('lib*/**/'))"
Unpatched: 78.3 msec per loop
Patched:   2.23 msec per loop

Patch to follow.
msg393558 - (view) Author: Barney Gale (barneygale) * Date: 2021-05-13 06:02
Flawed implementation, timings were bogus. Closing in shame.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88285
2021-05-13 06:02:42barneygalesetstatus: open -> closed
resolution: not a bug
messages: + msg393558

stage: resolved
2021-05-13 05:35:12barneygalecreate