]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-117586: Speed up `pathlib.Path.walk()` by working with strings (#117726)
authorBarney Gale <barney.gale@gmail.com>
Thu, 11 Apr 2024 00:26:53 +0000 (01:26 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Apr 2024 00:26:53 +0000 (01:26 +0100)
commit0cc71bde001950d3634c235e2b0d24cda6ce7dce
treeb7cdb33ccd2c1d0f793a8c3b60f590d9af8c0e0e
parent6258844c27e3b5a43816e7c559089a5fe0a47123
GH-117586: Speed up `pathlib.Path.walk()` by working with strings (#117726)

Move `pathlib.Path.walk()` implementation into `glob._Globber`. The new
`glob._Globber.walk()` classmethod works with strings internally, which is
a little faster than generating `Path` objects and keeping them normalized.
The `pathlib.Path.walk()` method converts the strings back to path objects.

In the private pathlib ABCs, our existing subclass of `_Globber` ensures
that `PathBase` instances are used throughout.

Follow-up to #117589.
Lib/glob.py
Lib/pathlib/__init__.py
Lib/pathlib/_abc.py
Misc/NEWS.d/next/Library/2024-04-10-21-08-32.gh-issue-117586.UCL__1.rst [new file with mode: 0644]