forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-111489: Add PyList_FromArrayMoveRef() function
Add new functions to create tuple and list from arrays: * PyTuple_FromArray(). * PyTuple_FromArrayMoveRef(). * PyList_FromArrayMoveRef(). Add tests on new functions.
- Loading branch information
Showing
14 changed files
with
252 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
from test.support import import_helper | ||
_testcapi = import_helper.import_module('_testcapi') | ||
|
||
|
||
class CAPITest(unittest.TestCase): | ||
def test_tuple_fromarray(self): | ||
# Test PyTuple_FromArray() | ||
tuple_fromarray = _testcapi.tuple_fromarraymoveref | ||
|
||
tup = tuple(object() for _ in range(5)) | ||
copy = tuple_fromarray(tup) | ||
self.assertEqual(copy, tup) | ||
|
||
def test_tuple_fromarraymoveref(self): | ||
# Test PyTuple_FromArrayMoveRef() | ||
tuple_fromarraymoveref = _testcapi.tuple_fromarraymoveref | ||
|
||
tup = tuple(object() for _ in range(5)) | ||
copy = tuple_fromarraymoveref(tup) | ||
self.assertEqual(copy, tup) |
7 changes: 7 additions & 0 deletions
7
Misc/NEWS.d/next/C API/2023-12-11-18-30-51.gh-issue-111489.S78zth.rst
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Add new functions to create :class:`tuple` and :class:`list` from arrays: | ||
|
||
* :c:func:`PyTuple_FromArray`. | ||
* :c:func:`PyTuple_FromArrayMoveRef`. | ||
* :c:func:`PyList_FromArrayMoveRef`. | ||
|
||
Patch by Victor Stinner. |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.