cpython (3.2): Advocate PyTuple_Pack instead of manual building of tuples

http://hg.python.org/cpython/rev/8267af6f370d changeset: 73838:8267af6f370d branch: 3.2 parent: 73836:93f64ae51fff user: Antoine Pitrou <solipsis@pitrou.net> date: Sat Dec 03 22:30:19 2011 +0100 summary: Advocate PyTuple_Pack instead of manual building of tuples files: Doc/faq/extending.rst | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -99,12 +99,7 @@ How do I use Py_BuildValue() to create a tuple of arbitrary length? ------------------------------------------------------------------- -You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using -``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of -``o``, so you have to :c:func:`Py_INCREF` it. Lists have similar functions -``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all -the tuple items to some value before you pass the tuple to Python code -- -``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value. +You can't. Use :c:func:`PyTuple_Pack` instead. How do I call an object's method from C? -- Repository URL: http://hg.python.org/cpython
participants (1)
-
antoine.pitrou