◐ Shell
clean mode source ↗

GH-119169: Slightly speed up `os.walk(topdown=True)` by barneygale · Pull Request #121431 · python/cpython

When `os.walk()` traverses into subdirectories in top-down mode, call
`os.path.join()` once to add a trailing slash, and use string concatenation
thereafter to generate child paths.

@barneygale barneygale changed the title GH-119186: Slightly speed up os.walk(topdown=True) GH-119169: Slightly speed up os.walk(topdown=True)

Jul 6, 2024

@barneygale

eendebakpt

@encukou

lkollar pushed a commit to lkollar/cpython that referenced this pull request

Sep 9, 2025
…121431)

pythonGH-119186: Slightly speed up `os.walk(topdown=True)`

When `os.walk()` traverses into subdirectories in top-down mode, call
`os.path.join()` once to add a trailing slash, and use string concatenation
thereafter to generate child paths.