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

Make minor performance improvements using ruff rules C4 and PERF #500

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Nov 24, 2023

Issue number of the reported bug or feature request: #

Describe your changes
A clear and concise description of the changes you have made.
Make minor performance improvements using ruff rules C4 and PERF.

9	PERF102	[*] When using only the keys of a dict use the `keys()` method
9	PERF401	[ ] Use a list comprehension to create a transformed list
4	C401   	[*] Unnecessary generator (rewrite as a `set` comprehension)
4	C402   	[*] Unnecessary generator (rewrite as a `dict` comprehension)
4	C408   	[*] Unnecessary `dict` call (rewrite as a literal)
3	C405   	[*] Unnecessary `list` literal (rewrite as a `set` literal)
1	C416   	[*] Unnecessary `dict` comprehension (rewrite using `dict()`)

Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.
% ruff --select=C4,PERF .

Additional context
Add any other context about your contribution here.

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c4b35f3) 92.32% compared to head (b556a9a) 92.22%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #500      +/-   ##
==========================================
- Coverage   92.32%   92.22%   -0.10%     
==========================================
  Files          91       91              
  Lines       11033    11033              
  Branches     1524     1524              
==========================================
- Hits        10186    10175      -11     
- Misses        842      853      +11     
  Partials        5        5              
Flag Coverage Δ
cpp 85.66% <ø> (-0.31%) ⬇️
python_and_cython 95.48% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@godlygeek
Copy link
Contributor

Everything under benchmarks/ is vendored code that we don't want to modify - please revert the changes to those files. We should instead configure ruff to not lint that directory. Also, we should configure ruff to always apply the C4 and PERF rules if we're going to make these changes, since otherwise there's nothing stopping us from regressing on them.

All the changes to our source code and tests seem fine, though. I think some of the dictionary literals are a bit less readable than the calls to the dict() constructor they're replacing, but the difference is probably not enough to worry about.

cclauss and others added 2 commits November 24, 2023 13:47
Apply ruff rules C4 and PERF to everything but our vendored benchmarks.
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek godlygeek force-pushed the minor-performance-improvements branch from 78638e6 to b556a9a Compare November 24, 2023 18:49
@godlygeek godlygeek self-assigned this Nov 24, 2023
@godlygeek godlygeek enabled auto-merge (rebase) November 24, 2023 18:53
@cclauss cclauss mentioned this pull request Nov 24, 2023
Copy link
Contributor

@godlygeek godlygeek left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the contribution, @cclauss!

@godlygeek godlygeek merged commit 138d9c5 into bloomberg:main Nov 24, 2023
33 of 36 checks passed
@cclauss cclauss deleted the minor-performance-improvements branch November 24, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants