-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
gh-122666: Tests for ast optimizations #122667
Conversation
Eclips4
commented
Aug 4, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Add tests for ast optimizations #122666
Hypothesis failure looks unrelated. |
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
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 proposed to write "Lines below are generated by running (...)" into a separated file, not move eval_opt_tests into a separated file. Would it be possible?
@@ -380,7 +380,6 @@ def main(): | |||
print("]") | |||
print("main()") | |||
raise SystemExit | |||
unittest.main() |
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.
This line is no longer needed since there's no unittest
in snippets.py
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.
LGTM.
@JelleZijlstra: Do you want to review this change?
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.
There are a few more optimizations this doesn't test. We could keep them for another PR if you want to, but they don't seem difficult to test:
not (a is b)
->a is not b
not (a in b)
->a not in b
(1,) * 3
->(1, 1, 1)
- It seems that in some cases it changes
%
formatting into f-strings but I haven't been able to trigger that __debug__
gets turned into True or False
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This is already tested by |
@JelleZijlstra do you think it's worth backporting this to the 3.13 branch? |
Yes, it's good to backport new tests in general so we can be more confident in bugfixes. |
Thanks @Eclips4 for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
(cherry picked from commit 9f9b00d) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-123359 is a backport of this pull request to the 3.13 branch. |
Oh, I forgot about 3.12 branch. I think it's also ok to backport it to 3.12. What do you think? |
We can't because the |
Oh, yeah, you're right. I agree that it's not worth the effort. |
(cherry picked from commit 9f9b00d) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>