Skip to content
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

Combine rstrip calls in trailing_whitespace check #1255

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

correctmost
Copy link
Contributor

This provides a small speed-up on large codebases (~90ms).

Stats

Before

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  1609756    0.432    0.000    0.432    0.000 {method 'rstrip' of 'str' objects}
Command Mean [s] Min [s] Max [s] Relative
pycodestyle . 18.178 ± 0.198 17.951 18.666 1.00

After

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  1137564    0.311    0.000    0.311    0.000 {method 'rstrip' of 'str' objects}
Command Mean [s] Min [s] Max [s] Relative
pycodestyle . 18.090 ± 0.155 17.784 18.264 1.00

Set-up

I profiled pycodestyle with the yt-dlp codebase because it is similar in composition to a private codebase I have.

git clone https://github.com/yt-dlp/yt-dlp.git
cd yt-dlp

git checkout ef36d517f9b05785d61abca7691d9ab7d63cc75c

# Callgraph command
python -m cProfile -o stats $(which pycodestyle)

# Benchmarking command
hyperfine --ignore-failure --warmup 2 --runs 10 --export-markdown=baseline.md 'pycodestyle .'

setup.cfg

[pycodestyle]
ignore = W504
max-line-length = 100

This provides a small speed-up on large codebases.
Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit c8e36a0 into PyCQA:main Aug 9, 2024
9 checks passed
@correctmost correctmost deleted the cm/combine-rstrips branch August 9, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants