-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 our terms of service and privacy 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
gh-89727: Improve os.walk complexity and speed #100671
Conversation
…:ovsyanka83/cpython into pythongh-89727/minor-os-walk-refactoring
@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
Outdated
Show resolved
Hide resolved
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.rst Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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.walk
to simplify it and speed it up.A small benchmark below.
"."
is this repository.