-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-36030: Add _PyTuple_FromArray() function #11954
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1276,45 +1276,19 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...) | |
| _Py_NO_INLINE PyObject * | ||
| _PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vstinner
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove _PyStack_AsTuple, but please do that in a second PR (once this one is merged, if it's merged ;-)).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove both |
||
| { | ||
| PyObject *args; | ||
| Py_ssize_t i; | ||
|
|
||
| args = PyTuple_New(nargs); | ||
| if (args == NULL) { | ||
| return NULL; | ||
| } | ||
|
|
||
| for (i=0; i < nargs; i++) { | ||
| PyObject *item = stack[i]; | ||
| Py_INCREF(item); | ||
| PyTuple_SET_ITEM(args, i, item); | ||
| } | ||
| return args; | ||
| return _PyTuple_FromArray(stack, nargs); | ||
| } | ||
|
|
||
|
|
||
| PyObject* | ||
| _PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs, | ||
| Py_ssize_t start, Py_ssize_t end) | ||
| { | ||
| PyObject *args; | ||
| Py_ssize_t i; | ||
|
|
||
| assert(0 <= start); | ||
| assert(end <= nargs); | ||
| assert(start <= end); | ||
|
|
||
| args = PyTuple_New(end - start); | ||
| if (args == NULL) { | ||
| return NULL; | ||
| } | ||
|
|
||
| for (i=start; i < end; i++) { | ||
| PyObject *item = stack[i]; | ||
| Py_INCREF(item); | ||
| PyTuple_SET_ITEM(args, i - start, item); | ||
| } | ||
| return args; | ||
| return _PyTuple_FromArray(stack + start, end - start); | ||
| } | ||
|
|
||
|
|
||
|
|
||
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.
@vstinner Was there a reason to export this as an API function, iso. using the
externkeyword?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 only started to no longer export symbols by using "extern" recently. Previously, I kept the habit of exporting symbols using PyAPI_FUNC/PyAPI_DATA. You can propose a PR to use extern.
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 see. Would that affect the Stable API, @encukou?
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.
No, nothing in
Include/internal/is in the limited API.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.
Great, thanks Petr.
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.
FYI, see GH-26352 and bpo-44231.