Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-89727: Improve os.walk complexity and speed#100671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-89727: Improve os.walk complexity and speed#100671
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…:ovsyanka83/cpython intopythongh-89727/minor-os-walk-refactoring
zmievsa commentedJan 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@JelleZijlstra I can't assign a reviewer but you merged the prior PR related to |
Misc/NEWS.d/next/Library/2023-01-01-23-57-00.gh-issue-89727.ojedHN.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Do you have a benchmark that shows this actually makes it faster? We lose a tuple allocation but gain a function call, so it's not completely obvious this should be faster. |
…edHN.rstCo-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
zmievsa commentedJan 2, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I made this MR because my initial benchmarking with Seems like the isinstance version is just a tiny bit (insignificantly) faster but I would still argue that it makes more sense than the original because it is slightly simpler. But what do you think? |
Thanks, seems like it's about a wash but since the new code is simpler and we never released the old version, seems fine to change this. |

Use isinstance for checking the top of the stack in
os.walkto simplify it and speed it up.A small benchmark below.

"."is this repository.