| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
There was a problem hiding this comment.
Please add some tests, probably to test_code.py.
You'll also probably need to change the __doc__ descriptor on function objects so it continues to work correctly.
Sorry, something went wrong.
|
Maybe the optimization pass should be updated as the hypothesis may not hold: Lines 2117 to 2119 in 9b14083 The generated bytecodes for the same function are different before and after this PR. |
Sorry, something went wrong.
|
FYI, we are in the process of removing small ints from the co_consts tuple: #125972 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. |
Sorry, something went wrong.
There are a few improvements we can make to the bytecode compiler once this PR is done. |
Sorry, something went wrong.
Yeah, what I concern is whether the constant removal optimization will lead to a unexpected results when the first element in co_consts is no longer None if there is no docstring. |
Sorry, something went wrong.
|
Currently, as the const removal optimization unconditionally keeps the first element in consts, None will present in co_consts even if co has no docstring if there is only one const (i.e., None itself). |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good. One small edit for the language reference.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for doing this.
This was one of those little things that's been bothering me for a while.
Glad to see it fixed
Sorry, something went wrong.
|
Update doc inspect.rst as well. |
Sorry, something went wrong.
There was a problem hiding this comment.
One small comment on inspect.rst.
Sorry, something went wrong.
|
The UI shows 2 jobs still in progress. But they have completed successfully 🤷♂️ |
Sorry, something went wrong.
|
Thanks for your review, it's my first PR merged into CPython! And I'm also interested in the following related optimizations. |
Sorry, something went wrong.
Congratulations! in your next PR, add your name to Misc/ACKS (we should have done it here, but too late now). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Hi @markshannon this is my attempt to implement #126072. Initially the value of CO_HAS_DOCSTRING is set as 0x0040, but I found it has been used by the CO_NOFREE in inspect.
cpython/Lib/inspect.py
Lines 409 to 411 in 85799f1
And I've tested it with the following code: See the test cases in changed test files
I'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/