Title: Improve performance of `os.walk()` · Issue #119169 · python/cpython · GitHub
Open Graph Title: Improve performance of `os.walk()` · Issue #119169 · python/cpython
X Title: Improve performance of `os.walk()` · Issue #119169 · python/cpython
Description: There are a couple of minor performance improvements possible in os.walk(): We don't need to manually pump the os.scandir iterator, given we handle exceptions from next() like exceptions from scandir() itself, i.e. by ignoring the proble...
Open Graph Description: There are a couple of minor performance improvements possible in os.walk(): We don't need to manually pump the os.scandir iterator, given we handle exceptions from next() like exceptions from scand...
X Description: There are a couple of minor performance improvements possible in os.walk(): We don't need to manually pump the os.scandir iterator, given we handle exceptions from next() like exceptions from s...
Opengraph URL: https://github.com/python/cpython/issues/119169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve performance of `os.walk()`","articleBody":"There are a couple of minor performance improvements possible in `os.walk()`:\r\n\r\n- We don't need to manually pump the `os.scandir` iterator, given we handle exceptions from `next()` like exceptions from `scandir()` itself, i.e. by ignoring the problematic directory and moving on. We can use a `for` loop like filthy casuals.\r\n- ~In bottom-up mode, we can handle exceptions from `entry.is_symlink()` in the same block as those from `entry.is_dir()`, which avoids a few temporary variables.~\r\n- In top-down mode, we can call `os.path.join()` once on a parent directory rather than for each child path.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-119186\n* gh-119473\n* gh-119573\n* gh-119750\n* gh-121431\n* gh-121432\n* gh-121433\n* gh-121435\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/barneygale","@type":"Person","name":"barneygale"},"datePublished":"2024-05-19T02:34:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/119169/cpython/issues/119169"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8a4d931d-1f19-816a-a64e-d4c8e029d2ff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D156:2B20E7:1453796:1BE22AC:69694D09 |
| html-safe-nonce | 0b3ba982cd5ee68daf8a56f14dfe6734621398ec02a7fd27b06071cdbe3fa50e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTU2OjJCMjBFNzoxNDUzNzk2OjFCRTIyQUM6Njk2OTREMDkiLCJ2aXNpdG9yX2lkIjoiODg1MTQyMDAyODE3OTQwMTk5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8782dccbddc4ff7271a90d6c414f69d33c4b84c761b145649dd8878fc3d45ca6 |
| hovercard-subject-tag | issue:2304394456 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/119169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0bfaf4487cb5b4cd0af0b4e18e89eb6dd2d65de777e49f147660459c33de8e29/python/cpython/issues/119169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0bfaf4487cb5b4cd0af0b4e18e89eb6dd2d65de777e49f147660459c33de8e29/python/cpython/issues/119169 |
| og:image:alt | There are a couple of minor performance improvements possible in os.walk(): We don't need to manually pump the os.scandir iterator, given we handle exceptions from next() like exceptions from scand... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | barneygale |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width