Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48383bf

Browse files
committed
Advocate PyTuple_Pack instead of manual building of tuples
1 parent f352040 commit 48383bf

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

Doc/faq/extending.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ many other useful protocols.
9999
How do I use Py_BuildValue() to create a tuple of arbitrary length?
100100
-------------------------------------------------------------------
101101

102-
You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using
103-
``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of
104-
``o``, so you have to :c:func:`Py_INCREF` it. Lists have similar functions
105-
``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all
106-
the tuple items to some value before you pass the tuple to Python code --
107-
``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value.
102+
You can't. Use :c:func:`PyTuple_Pack` instead.
108103

109104

110105
How do I call an object's method from C?

0 commit comments

Comments
 (0)