-
Notifications
You must be signed in to change notification settings - Fork 144
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
Enabling Perflint checks #3403
base: main
Are you sure you want to change the base?
Enabling Perflint checks #3403
Conversation
tmt/export/nitrate.py
Outdated
@@ -84,22 +84,17 @@ def _nitrate_find_fmf_testcases(test: 'tmt.Test') -> Iterator[Any]: | |||
""" | |||
import tmt.base | |||
assert nitrate | |||
for component in test.component: | |||
try: | |||
with suppress(tmt.utils.StructuredFieldError, nitrate.NitrateError): |
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.
Does this change make sense @happz? I'm thinking
try:
with suppress(tmt.utils.StructuredFieldError):
except nitrate.NitrateError:
pass
but not sure if there is an advantage in doing so.
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.
changed in 64f6242
@martinhoyer Huston, a little problem - https://stackoverflow.com/questions/34566806/why-use-contextlib-suppress-as-opposed-to-try-except-with-pass I've checked same timeit command on python3.13 (my laptop) and it indeed is much worse with suppress. |
Nice, good info. Thanks! Actually the supress wasn't added as part of performance optimization. The perflint is complaining about try except being inside the loop. btw, have you run the timeits with some of the changed code here? Just curious if it's also slower. |
Out of curiosity, I've tried to solve the remaining PERF203 and tested modifying this function:
to
An the test results over a milion iterations: Anyway, I'm going to do something useful. |
Mostly dict-index-missing-items (PLC0206). Use license-file as per PEP 639.
Will probably have negligible performance improvements, but it seems like a low-hanging fruit.
The PERF203 would be a bit more tricky to address fully, but I've at least tried to fix those simpler cases.
Depends on #3402
Pull Request Checklist