GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-115653: Add docs for the PyCode_GetFirstFree and correct return type for the PyCode_GetNumFree by wrongnull · Pull Request #115654 · python/cpython Conversation
|
|
BTW, should |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| .. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) | ||
|
|
||
| Return the number of local + cell variables in *co*. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Document what the API does, not its implementation details: PyCode_GetFirstFree returns the position (or offset) of the first free variable in co.
FTR: @markshannon and @iritkatriel introduced this API in gh-100721. It is available via Python.h.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done. But my question above still stands. If I'm right I might make a separate pull request for this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
See the PR I linked to, especially #100721 (comment) and 49ca044.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you. If there is anything else here that I could fix, I'll be happy to do it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would still like to hear from either @markshannon or @iritkatriel; I'm not sure this was intended as a public API.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It was and it wasn't. We don't really want to expose it, but if we don't then Cython and other C extensions will access the internal fields directly, which is worse.
Now that we have an unstable API, it should probably be part of that.
I'd like all code object C APIs to be unstable, but it's probably too late for that.
Maybe rename it to PyUnstableCode_GetFirstFree?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename it to PyUnstableCode_GetFirstFree?
Sounds like a good idea, but since it is already included in 3.12, we have to deprecate PyCode_GetFirstFree and PyUnstableCode_GetFirstFree in 3.13.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Follow-up issue: #115756.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
In general, please split up multiple changes in atomic PRs; the distinct changes might not have equal backport requirements. For these two changes it looks to me both of them are applicable for a 3.12 backport only, so you're fine. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .. c:function:: int PyCode_GetNumFree(PyCodeObject *co) | ||
| .. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co) | ||
|
|
||
| Return the number of free variables in *co*. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Return the number of free variables in *co*. | |
| Return the number of free variables in a code object. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| .. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) | ||
|
|
||
| Return the position of first free variable in *co*. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Return the position of first free variable in *co*. | |
| Return the position of the first free variable in a code object. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @wrongnull for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Correct the return type of the PyCode_GetNumFree() documentation. (cherry picked from commit 10fc467) Co-authored-by: Bogdan Romanyuk <[email protected]>
|
GH-115752 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co) | ||
|
|
||
| Return the number of free variables in *co*. | ||
| Return the number of free variables in a code object. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@vstinner, I think this is the suggested style:
| Return the number of free variables in a code object. | |
| Return the number of free variables in code object *co*. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just merged the change. Is it worth it to change the style, or is it ok to merge PR gh-115752 backport? I let you decide :-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No, it's not worth it to change the style, but I think we should try to keep it in mind for next time ;)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Correct the return type of the PyCode_GetNumFree() documentation.
Correct the return type of the PyCode_GetNumFree() documentation.
Correct the return type of the PyCode_GetNumFree() documentation.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.