-
Notifications
You must be signed in to change notification settings - Fork 133
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
Fix ruff compressions and performance issues #490
Fix ruff compressions and performance issues #490
Conversation
48ae689
to
01a6dab
Compare
.github/workflows/main.yml
Outdated
@@ -7,6 +7,7 @@ on: | |||
jobs: | |||
test: | |||
strategy: | |||
fail-fast: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can we leave this on. It seems wasteful to run everything if something has failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasteful of compute time or developer time? fail-fast: false
saves developers time because they see all failing jobs in a single run and can understand the root cause faster and be more efficient in fixing. If this helps them make fewer commits then it also reduces compute time.
fail-fast: true
is a good default for GitHub because it reduces compute time however it forces the developer to go thru multiple commits when debugging multiple problems.,
autoapi/inheritance_diagrams.py
Outdated
if isinstance(child, astroid.ClassDef): | ||
classes.append(child) | ||
return classes | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of multi-line list comprehensions. I think we sacrifice readability for a minimal performance benefit. Please could this stay as-is.
docs/changes/490.misc.rst
Outdated
@@ -0,0 +1 @@ | |||
Fix ruff compressions and performance issues, limit new version of sphinx, add Py312,Py313 to trove classifiers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sphinx issue has been addressed and the classifiers have been added since this was written. Please could you correct these.
3536d95
to
ee2f8ea
Compare
%
ruff check --select=C4,PERF --statistics .
%
ruff rule PERF401
manual-list-comprehension (PERF401)
Derived from the Perflint linter.
What it does
Checks for
for
loops that can be replaced by a list comprehension.Why is this bad?
When creating a transformed list from an existing list using a for-loop,
prefer a list comprehension. List comprehensions are more readable and
more performant.
Using the below as an example, the list comprehension is ~10% faster on
Python 3.11, and ~25% faster on Python 3.10.
Note that, as with all
perflint
rules, this is only intended as amicro-optimization, and will have a negligible impact on performance in
most cases.
Example
Use instead:
If you're appending to an existing list, use the
extend
method instead: