René's URL Explorer Experiment


Title: GH-119169: Speed up `os.walk(topdown=False)` by barneygale · Pull Request #119186 · python/cpython · GitHub

Open Graph Title: GH-119169: Speed up `os.walk(topdown=False)` by barneygale · Pull Request #119186 · python/cpython

X Title: GH-119169: Speed up `os.walk(topdown=False)` by barneygale · Pull Request #119186 · python/cpython

Description: Add entries to the stack while iterating over os.scandir() results, rather than afterwards. Issue: Improve performance of os.walk() #119169

Open Graph Description: Add entries to the stack while iterating over os.scandir() results, rather than afterwards. Issue: Improve performance of os.walk() #119169

X Description: Add entries to the stack while iterating over os.scandir() results, rather than afterwards. Issue: Improve performance of os.walk() #119169

Opengraph URL: https://github.com/python/cpython/pull/119186

X: @github

direct link

Domain: github.com

route-pattern/_view_fragments/voltron/pull_requests/show/:user_id/:repository/:id/pull_request_layout(.:format)
route-controllervoltron_pull_requests_fragments
route-actionpull_request_layout
fetch-noncev2:1152f897-d97a-fa72-04d9-982dbd6a3ab1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id93C2:25FEA8:1D65976:293E2EC:696A5546
html-safe-nonce441273162fa982c8dac05af47780d3ca583789b7fa2fe3daf3b871bda09b0b11
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0MyOjI1RkVBODoxRDY1OTc2OjI5M0UyRUM6Njk2QTU1NDYiLCJ2aXNpdG9yX2lkIjoiMTA5MjA2NDE3MzQzMzE4MTUxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccec806c4545314118e716a0744e0ac7062e0aa50823b82384ccdab6a247f27ae
hovercard-subject-tagpull_request:1877265430
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/pull_requests_fragments/pull_request_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/voltron/pull_requests/show/python/cpython/119186/pull_request_layout
twitter:imagehttps://opengraph.githubassets.com/111f8df785d8758719b68b0ee59932ce56356acce3de65a4efba847499f418db/python/cpython/pull/119186
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/111f8df785d8758719b68b0ee59932ce56356acce3de65a4efba847499f418db/python/cpython/pull/119186
og:image:altAdd entries to the stack while iterating over os.scandir() results, rather than afterwards. Issue: Improve performance of os.walk() #119169
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebarneygale
hostnamegithub.com
expected-hostnamegithub.com
None3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release63c426b30d262aba269ef14c40e3c817b384cd61
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/119186#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F119186
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F119186
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fpull_requests_fragments%2Fpull_request_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/119186
Reloadhttps://github.com/python/cpython/pull/119186
Reloadhttps://github.com/python/cpython/pull/119186
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/119186
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/119186
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
Jump to bottomhttps://github.com/python/cpython/pull/119186#issue-comment-box
barneygalehttps://github.com/barneygale
python:mainhttps://github.com/python/cpython/tree/main
barneygale:os-walk-speeduphttps://github.com/barneygale/cpython/tree/os-walk-speedup
GH-119169: Speed up os.walk(topdown=False) https://github.com/python/cpython/pull/119186#top
barneygalehttps://github.com/barneygale
python:mainhttps://github.com/python/cpython/tree/main
barneygale:os-walk-speeduphttps://github.com/barneygale/cpython/tree/os-walk-speedup
Conversation 3 https://github.com/python/cpython/pull/119186
Commits 12 https://github.com/python/cpython/pull/119186/commits
Checks 0 https://github.com/python/cpython/pull/119186/checks
Files changed https://github.com/python/cpython/pull/119186/files
Please reload this pagehttps://github.com/python/cpython/pull/119186
https://github.co/hiddenchars
https://github.com/python/cpython/pull/{{ revealButtonHref }}
https://github.com/barneygale
barneygalehttps://github.com/barneygale
May 19, 2024https://github.com/python/cpython/pull/119186#issue-2304744343
Please reload this pagehttps://github.com/python/cpython/pull/119186
Improve performance of os.walk() #119169https://github.com/python/cpython/issues/119169
Please reload this pagehttps://github.com/python/cpython/pull/119186
https://github.com/barneygale
pythonGH-119169https://github.com/python/cpython/issues/119169
: Speed uphttps://github.com/python/cpython/pull/119186/commits/74a495c6b1dee7b1c71e0b82ca1ab8362aceda78
os.walk()https://github.com/python/cpython/pull/119186/commits/74a495c6b1dee7b1c71e0b82ca1ab8362aceda78
74a495chttps://github.com/python/cpython/pull/119186/commits/74a495c6b1dee7b1c71e0b82ca1ab8362aceda78
https://github.com/apps/bedevere-app
bedevere-apphttps://github.com/apps/bedevere-app
awaiting core review https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22awaiting%20core%20review%22
May 19, 2024https://github.com/python/cpython/pull/119186#event-12859058646
https://github.com/apps/bedevere-app
bedevere-apphttps://github.com/apps/bedevere-app
May 19, 2024 https://github.com/python/cpython/pull/119186#ref-issue-2304394456
Improve performance of os.walk() #119169 https://github.com/python/cpython/issues/119169
https://github.com/barneygale
barneygalehttps://github.com/barneygale
performance https://github.com/python/cpython/issues?q=state%3Aopen%20label%3Aperformance
awaiting core review https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22awaiting%20core%20review%22
May 19, 2024https://github.com/python/cpython/pull/119186#event-12859058894
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
May 20, 2024https://github.com/python/cpython/pull/119186#issuecomment-2121109882
@serhiy-storchakahttps://github.com/serhiy-storchaka
Please reload this pagehttps://github.com/python/cpython/pull/119186
barneygalehttps://github.com/barneygale
May 23, 2024 09:26https://github.com/python/cpython/pull/119186#commits-pushed-eb4b6ff
https://github.com/barneygale
Merge branch 'main' into os-walk-speeduphttps://github.com/python/cpython/pull/119186/commits/eb4b6ff605cbec93497b1aa8fd6768fd2cc7eaf3
eb4b6ffhttps://github.com/python/cpython/pull/119186/commits/eb4b6ff605cbec93497b1aa8fd6768fd2cc7eaf3
https://github.com/barneygale
Simplify bottom-up implementation.https://github.com/python/cpython/pull/119186/commits/46a3ba54ac805786649f8ab0e5dd0ace2051f58b
46a3ba5https://github.com/python/cpython/pull/119186/commits/46a3ba54ac805786649f8ab0e5dd0ace2051f58b
https://github.com/barneygale
barneygalehttps://github.com/barneygale
May 23, 2024 08:46https://github.com/python/cpython/pull/119186#event-12905807915
https://github.com/barneygale
barneygalehttps://github.com/barneygale
May 23, 2024https://github.com/python/cpython/pull/119186#issuecomment-2127875020
#119473https://github.com/python/cpython/pull/119473
Please reload this pagehttps://github.com/python/cpython/pull/119186
barneygalehttps://github.com/barneygale
May 30, 2024 05:06https://github.com/python/cpython/pull/119186#commits-pushed-2d957a8
https://github.com/barneygale
Merge branch 'main' into os-walk-speeduphttps://github.com/python/cpython/pull/119186/commits/2d957a8474ff0979fe8056275d3f208c46732103
2d957a8https://github.com/python/cpython/pull/119186/commits/2d957a8474ff0979fe8056275d3f208c46732103
https://github.com/barneygale
Apply the same changes to fwalk()https://github.com/python/cpython/pull/119186/commits/a6382026d696e3be9f6d057e347949bd1204e3b1
a638202https://github.com/python/cpython/pull/119186/commits/a6382026d696e3be9f6d057e347949bd1204e3b1
https://github.com/barneygale
barneygalehttps://github.com/barneygale
May 30, 2024https://github.com/python/cpython/pull/119186#event-12979756523
https://github.com/barneygale
Simplify code slightlyhttps://github.com/python/cpython/pull/119186/commits/91b5a78584c1701af18938870c7fb4b33cd5ba4c
91b5a78https://github.com/python/cpython/pull/119186/commits/91b5a78584c1701af18938870c7fb4b33cd5ba4c
https://github.com/barneygale
barneygalehttps://github.com/barneygale
Jul 6, 2024 https://github.com/python/cpython/pull/119186#ref-pullrequest-2313669034
GH-119169: Skip reversing sibling directories in os.[f]walk(topdown=False) #119473 https://github.com/python/cpython/pull/119473
barneygalehttps://github.com/barneygale
Jul 6, 2024 https://github.com/python/cpython/pull/119186#ref-commit-e5f62ec
https://github.com/barneygale
pythonGH-119186https://github.com/python/cpython/pull/119186
: Slightly speed uphttps://github.com/barneygale/cpython/commit/e5f62ec5cd0dde14777754c6ea05034b738f3a1f
os.walk(topdown=True)https://github.com/barneygale/cpython/commit/e5f62ec5cd0dde14777754c6ea05034b738f3a1f
e5f62echttps://github.com/barneygale/cpython/commit/e5f62ec5cd0dde14777754c6ea05034b738f3a1f
barneygalehttps://github.com/barneygale
July 6, 2024 14:39https://github.com/python/cpython/pull/119186#commits-pushed-b32c1c0
https://github.com/barneygale
Simplify exception handling in fwalk()https://github.com/python/cpython/pull/119186/commits/b32c1c0641f9cec2e6788b0ae49ba61d9b9b3d75
b32c1c0https://github.com/python/cpython/pull/119186/commits/b32c1c0641f9cec2e6788b0ae49ba61d9b9b3d75
https://github.com/barneygale
Merge branch 'main' into os-walk-speeduphttps://github.com/python/cpython/pull/119186/commits/8c7cf04fd2bc9a7b80fc8da2a2e2f48757383d74
8c7cf04https://github.com/python/cpython/pull/119186/commits/8c7cf04fd2bc9a7b80fc8da2a2e2f48757383d74
https://github.com/barneygale
Undo trailing slash optimisation (moved to another PR)https://github.com/python/cpython/pull/119186/commits/efd31e2ef5ce2c8d5132d165bef861b8dca6ae90
efd31e2https://github.com/python/cpython/pull/119186/commits/efd31e2ef5ce2c8d5132d165bef861b8dca6ae90
https://github.com/barneygale
Undo fwalk() changes.https://github.com/python/cpython/pull/119186/commits/5b89c5759f898f616fd2c51f3b38294c8c079369
5b89c57https://github.com/python/cpython/pull/119186/commits/5b89c5759f898f616fd2c51f3b38294c8c079369
https://github.com/barneygale
Fix news entry.https://github.com/python/cpython/pull/119186/commits/525618ce65a525eae29c64d414644f45f994647f
525618chttps://github.com/python/cpython/pull/119186/commits/525618ce65a525eae29c64d414644f45f994647f
https://github.com/barneygale
barneygalehttps://github.com/barneygale
Jul 6, 2024https://github.com/python/cpython/pull/119186#event-13411585129
barneygalehttps://github.com/barneygale
Jul 6, 2024 https://github.com/python/cpython/pull/119186#ref-commit-abce81c
https://github.com/barneygale
pythonGH-119186https://github.com/python/cpython/pull/119186
: Slightly speed uphttps://github.com/barneygale/cpython/commit/abce81cb8942d60d8b5b04e4b782f0bb4397c5ba
os.walk()https://github.com/barneygale/cpython/commit/abce81cb8942d60d8b5b04e4b782f0bb4397c5ba
abce81chttps://github.com/barneygale/cpython/commit/abce81cb8942d60d8b5b04e4b782f0bb4397c5ba
https://github.com/barneygale
barneygalehttps://github.com/barneygale
Jul 6, 2024https://github.com/python/cpython/pull/119186#event-13411718658
barneygalehttps://github.com/barneygale
Jul 8, 2024 https://github.com/python/cpython/pull/119186#ref-commit-6534a36
https://github.com/barneygale
Merge branch 'main' intohttps://github.com/barneygale/cpython/commit/6534a3607465135e73500670c144e01c232f29dc
pythongh-119186https://github.com/python/cpython/pull/119186
-joininghttps://github.com/barneygale/cpython/commit/6534a3607465135e73500670c144e01c232f29dc
6534a36https://github.com/barneygale/cpython/commit/6534a3607465135e73500670c144e01c232f29dc
https://github.com/barneygale
Merge branch 'main' into os-walk-speeduphttps://github.com/python/cpython/pull/119186/commits/d3af6550b7b128c851dc530f7bc7160cdedec5f5
d3af655https://github.com/python/cpython/pull/119186/commits/d3af6550b7b128c851dc530f7bc7160cdedec5f5
https://github.com/barneygale
barneygalehttps://github.com/barneygale
Jul 8, 2024https://github.com/python/cpython/pull/119186#issuecomment-2214939002
#119473https://github.com/python/cpython/pull/119473
Please reload this pagehttps://github.com/python/cpython/pull/119186
https://github.com/barneygale
barneygalehttps://github.com/barneygale
Jul 8, 2024https://github.com/python/cpython/pull/119186#event-13428298789
encukouhttps://github.com/encukou
Sep 2, 2025 https://github.com/python/cpython/pull/119186#ref-commit-7d6bd57
https://github.com/encukou
Merge branch 'main' intohttps://github.com/barneygale/cpython/commit/7d6bd578650999e8453683e4f05cd23717ee4331
pythongh-119186https://github.com/python/cpython/pull/119186
-joininghttps://github.com/barneygale/cpython/commit/7d6bd578650999e8453683e4f05cd23717ee4331
7d6bd57https://github.com/barneygale/cpython/commit/7d6bd578650999e8453683e4f05cd23717ee4331
encukouhttps://github.com/encukou
Sep 3, 2025 https://github.com/python/cpython/pull/119186#ref-commit-b19ad11
https://github.com/barneygale
GH-119169https://github.com/python/cpython/issues/119169
: Slightly speed uphttps://github.com/python/cpython/commit/b19ad110278344d01a6f8d008c4cda3e07dc50e9
os.walk(topdown=True)https://github.com/python/cpython/commit/b19ad110278344d01a6f8d008c4cda3e07dc50e9
(https://github.com/python/cpython/commit/b19ad110278344d01a6f8d008c4cda3e07dc50e9
GH-121431https://github.com/python/cpython/pull/121431
)https://github.com/python/cpython/commit/b19ad110278344d01a6f8d008c4cda3e07dc50e9
b19ad11https://github.com/python/cpython/commit/b19ad110278344d01a6f8d008c4cda3e07dc50e9
GH-119186https://github.com/python/cpython/pull/119186
lkollarhttps://github.com/lkollar
Sep 9, 2025 https://github.com/python/cpython/pull/119186#ref-commit-02b5cb3
https://github.com/barneygale
https://github.com/lkollar
pythonGH-119169https://github.com/python/cpython/issues/119169
: Slightly speed uphttps://github.com/lkollar/cpython/commit/02b5cb356b5f1b34910805957e54acc6ecb6e5a2
os.walk(topdown=True)https://github.com/lkollar/cpython/commit/02b5cb356b5f1b34910805957e54acc6ecb6e5a2
(https://github.com/lkollar/cpython/commit/02b5cb356b5f1b34910805957e54acc6ecb6e5a2
pythonGH-…https://github.com/python/cpython/pull/121431
02b5cb3https://github.com/lkollar/cpython/commit/02b5cb356b5f1b34910805957e54acc6ecb6e5a2
…121431https://github.com/python/cpython/pull/121431
pythonGH-119186https://github.com/python/cpython/pull/119186
Sign up for freehttps://github.com/join?source=comment-repo
Sign in to commenthttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F119186
performance https://github.com/python/cpython/issues?q=state%3Aopen%20label%3Aperformance
Please reload this pagehttps://github.com/python/cpython/pull/119186
https://github.com/barneygale
https://github.com/vstinner
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.