gh-111489: Add PyTuple_FromArray() function by vstinner · Pull Request #139691 · python/cpython
|
|
||
| tup = () | ||
| copy = tuple_fromarray(tup) | ||
| self.assertIs(copy, tup) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not the empty tuple singleton a CPython implementation detail?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole file is a CPython implementation detail (_testcapi), no?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Comment on lines +42 to +43
| Create a tuple of *size* items and copy references from *array* to the new | ||
| tuple. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to formulate this in words more similar to PyTuple_New() or PyTuple_Pack() ("Return a new tuple object of size ... "), but this is not so important.
I exchanged array and size parameters, new API:
PyObject* PyTuple_FromArray(Py_ssize_t size, PyObject *const *array)
I exchanged array and size parameters, new API: (...)
Sorry, I changed my preference back to (array, size) as before :-) See the API discussion at: capi-workgroup/decisions#79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters