Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@zmievsa
Copy link
Contributor

Use isinstance for checking the top of the stack inos.walk to simplify it and speed it up.

A small benchmark below."." is this repository.
image

@AlexWaygoodAlexWaygood added the performancePerformance or resource usage labelJan 2, 2023
@zmievsa
Copy link
ContributorAuthor

zmievsa commentedJan 2, 2023
edited
Loading

@JelleZijlstra I can't assign a reviewer but you merged the prior PR related toos.walk so I decided that it makes sense to ping you here. I hope that's ok :))

@JelleZijlstraJelleZijlstra self-requested a reviewJanuary 2, 2023 03:40
@JelleZijlstra
Copy link
Member

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
Copy link
ContributorAuthor

zmievsa commentedJan 2, 2023
edited
Loading

I made this MR because my initial benchmarking withpathlib.Path.walk andos.walk was quite obvious. However, after timing it a few more times I have gotten inconsistent results.

image

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?

@JelleZijlstra
Copy link
Member

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.

zmievsa reacted with hooray emojizmievsa reacted with heart emoji

@JelleZijlstraJelleZijlstra merged commit73097d9 intopython:mainJan 2, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

Assignees

No one assigned

Labels

performancePerformance or resource usage

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@zmievsa@JelleZijlstra@bedevere-bot@AlexWaygood@Ovsyanka83

[8]ページ先頭

©2009-2025 Movatter.jp