Improve performance of `os.walk()`
オープン
まだ誰も着手していません。
performance
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
There are a couple of minor performance improvements possible in os.walk():
- We don't need to manually pump the
os.scandiriterator, given we handle exceptions fromnext()like exceptions fromscandir()itself, i.e. by ignoring the problematic directory and moving on. We can use aforloop like filthy casuals. In bottom-up mode, we can handle exceptions fromentry.is_symlink()in the same block as those fromentry.is_dir(), which avoids a few temporary variables.- In top-down mode, we can call
os.path.join()once on a parent directory rather than for each child path.
Linked PRs
- gh-119186
- gh-119473
- gh-119573
- gh-119750
- gh-121431
- gh-121432
- gh-121433
- gh-121435
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
os.walk() のエントリポイントから始め、os.scandir()、entry.is_dir()、entry.is_symlink()、os.path.join() の使用箇所を調査してください。変更を加える前に、関連付けられた PR gh-119186、gh-119473、gh-119573、gh-119750、gh-121431、gh-121432、gh-121433、gh-121435 を確認してください。提案されたパフォーマンス改善によって例外処理と走査の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- operating-systems
- issue の種類
- リファクタリング
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 20/100