[New-bugs-announce] [issue44119] Use glob.glob() to implement pathlib.Path.glob()

Barney Gale report at bugs.python.org
Thu May 13 01:35:12 EDT 2021


New submission from Barney Gale <barney.gale at gmail.com>:

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.

----------
components: Library (Lib)
messages: 393556
nosy: barneygale
priority: normal
severity: normal
status: open
title: Use glob.glob() to implement pathlib.Path.glob()
type: performance
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44119>
_______________________________________


More information about the New-bugs-announce mailing list