Skip to content

Combine rstrip calls in trailing_whitespace check - #1255

Merged
asottile merged 1 commit into
PyCQA:mainfrom
correctmost:cm/combine-rstrips
Aug 9, 2024
Merged

asottile merged 1 commit into
PyCQA:mainfrom
correctmost:cm/combine-rstrips

Conversation

@correctmost

Copy link
Copy Markdown
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.

@asottile asottile left a comment

Copy link
Copy Markdown
Member

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
@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