Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-126072: do not addNone toco_consts if no docstring#126101
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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 add some tests, probably totest_code.py.
You'll also probably need to change the__doc__ descriptor on function objects so it continues to work correctly.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
xuantengh commentedOct 29, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Maybe the optimization pass should be updated as the hypothesis may not hold: Lines 2117 to 2119 in9b14083
The generated bytecodes for the same function are different before and after this PR. |
FYI, we are in the process of removing small ints from the Can you change the ints in your tests to strings. Doing so will also help test that non-docstring strings do not get interpreted as docstrings. |
There are a few improvements we can make to the bytecode compiler once this PR is done. |
xuantengh commentedOct 29, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yeah, what I concern is whether the constant removal optimization will lead to a unexpected results when the first element in |
Currently, as the const removal optimization unconditionally keeps the first element in consts, |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Looks good. One small edit for the language reference.
Uh oh!
There was an error while loading.Please reload this page.
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.
Thanks for doing this.
This was one of those little things that's been bothering me for a while.
Glad to see it fixed
Uh oh!
There was an error while loading.Please reload this page.
Update doc |
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.
One small comment on inspect.rst.
Uh oh!
There was an error while loading.Please reload this page.
The UI shows 2 jobs still in progress. But they have completed successfully 🤷♂️ |
35df4eb intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks for your review, it's my first PR merged into CPython! And I'm also interested in the following related optimizations. |
Congratulations! in your next PR, add your name to |
Uh oh!
There was an error while loading.Please reload this page.
Hi@markshannon this is my attempt to implement#126072. Initially the value of
CO_HAS_DOCSTRINGis set as0x0040, but I found it has been used by theCO_NOFREEininspect.cpython/Lib/inspect.py
Lines 409 to 411 in85799f1
And I've tested it with the following code:See the test cases in changed test filesI've also updated the related documentation, but maybe there is something I missed. Please help me improve this PR, thank you!
📚 Documentation preview 📚:https://cpython-previews--126101.org.readthedocs.build/