tuple.html 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  6. <meta property="og:title" content="Tuple Objects" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/c-api/tuple.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Struct Sequence Objects: Struct sequence objects are the C equivalent of namedtuple() objects, i.e. a sequence whose items can also be accessed through attributes. To create a struct sequence, you ..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Struct Sequence Objects: Struct sequence objects are the C equivalent of namedtuple() objects, i.e. a sequence whose items can also be accessed through attributes. To create a struct sequence, you ..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>Tuple Objects &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
  21. <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
  22. <script src="../_static/jquery.js"></script>
  23. <script src="../_static/underscore.js"></script>
  24. <script src="../_static/doctools.js"></script>
  25. <script src="../_static/sidebar.js"></script>
  26. <link rel="search" type="application/opensearchdescription+xml"
  27. title="Search within Python 3.12.0 documentation"
  28. href="../_static/opensearch.xml"/>
  29. <link rel="author" title="About these documents" href="../about.html" />
  30. <link rel="index" title="Index" href="../genindex.html" />
  31. <link rel="search" title="Search" href="../search.html" />
  32. <link rel="copyright" title="Copyright" href="../copyright.html" />
  33. <link rel="next" title="List Objects" href="list.html" />
  34. <link rel="prev" title="Unicode Objects and Codecs" href="unicode.html" />
  35. <link rel="canonical" href="https://docs.python.org/3/c-api/tuple.html" />
  36. <style>
  37. @media only screen {
  38. table.full-width-table {
  39. width: 100%;
  40. }
  41. }
  42. </style>
  43. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  44. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  45. <script type="text/javascript" src="../_static/copybutton.js"></script>
  46. <script type="text/javascript" src="../_static/menu.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">Tuple Objects</a></li>
  86. <li><a class="reference internal" href="#struct-sequence-objects">Struct Sequence Objects</a></li>
  87. </ul>
  88. </div>
  89. <div>
  90. <h4>Previous topic</h4>
  91. <p class="topless"><a href="unicode.html"
  92. title="previous chapter">Unicode Objects and Codecs</a></p>
  93. </div>
  94. <div>
  95. <h4>Next topic</h4>
  96. <p class="topless"><a href="list.html"
  97. title="next chapter">List Objects</a></p>
  98. </div>
  99. <div role="note" aria-label="source link">
  100. <h3>This Page</h3>
  101. <ul class="this-page-menu">
  102. <li><a href="../bugs.html">Report a Bug</a></li>
  103. <li>
  104. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/tuple.rst"
  105. rel="nofollow">Show Source
  106. </a>
  107. </li>
  108. </ul>
  109. </div>
  110. </nav>
  111. </div>
  112. </div>
  113. <div class="related" role="navigation" aria-label="related navigation">
  114. <h3>Navigation</h3>
  115. <ul>
  116. <li class="right" style="margin-right: 10px">
  117. <a href="../genindex.html" title="General Index"
  118. accesskey="I">index</a></li>
  119. <li class="right" >
  120. <a href="../py-modindex.html" title="Python Module Index"
  121. >modules</a> |</li>
  122. <li class="right" >
  123. <a href="list.html" title="List Objects"
  124. accesskey="N">next</a> |</li>
  125. <li class="right" >
  126. <a href="unicode.html" title="Unicode Objects and Codecs"
  127. accesskey="P">previous</a> |</li>
  128. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  129. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  130. <li class="switchers">
  131. <div class="language_switcher_placeholder"></div>
  132. <div class="version_switcher_placeholder"></div>
  133. </li>
  134. <li>
  135. </li>
  136. <li id="cpython-language-and-version">
  137. <a href="../index.html">3.12.0 Documentation</a> &#187;
  138. </li>
  139. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  140. <li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> &#187;</li>
  141. <li class="nav-item nav-item-this"><a href="">Tuple Objects</a></li>
  142. <li class="right">
  143. <div class="inline-search" role="search">
  144. <form class="inline-search" action="../search.html" method="get">
  145. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  146. <input type="submit" value="Go" />
  147. </form>
  148. </div>
  149. |
  150. </li>
  151. <li class="right">
  152. <label class="theme-selector-label">
  153. Theme
  154. <select class="theme-selector" oninput="activateTheme(this.value)">
  155. <option value="auto" selected>Auto</option>
  156. <option value="light">Light</option>
  157. <option value="dark">Dark</option>
  158. </select>
  159. </label> |</li>
  160. </ul>
  161. </div>
  162. <div class="document">
  163. <div class="documentwrapper">
  164. <div class="bodywrapper">
  165. <div class="body" role="main">
  166. <section id="tuple-objects">
  167. <span id="tupleobjects"></span><h1>Tuple Objects<a class="headerlink" href="#tuple-objects" title="Permalink to this headline">¶</a></h1>
  168. <span class="target" id="index-0"></span><dl class="c type">
  169. <dt class="sig sig-object c" id="c.PyTupleObject">
  170. <span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTupleObject</span></span></span><a class="headerlink" href="#c.PyTupleObject" title="Permalink to this definition">¶</a><br /></dt>
  171. <dd><p>This subtype of <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> represents a Python tuple object.</p>
  172. </dd></dl>
  173. <dl class="c var">
  174. <dt class="sig sig-object c" id="c.PyTuple_Type">
  175. <a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_Type</span></span></span><a class="headerlink" href="#c.PyTuple_Type" title="Permalink to this definition">¶</a><br /></dt>
  176. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This instance of <a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyTypeObject</span></code></a> represents the Python tuple type; it
  177. is the same object as <a class="reference internal" href="../library/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> in the Python layer.</p>
  178. </dd></dl>
  179. <dl class="c function">
  180. <dt class="sig sig-object c" id="c.PyTuple_Check">
  181. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_Check</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_Check" title="Permalink to this definition">¶</a><br /></dt>
  182. <dd><p>Return true if <em>p</em> is a tuple object or an instance of a subtype of the
  183. tuple type. This function always succeeds.</p>
  184. </dd></dl>
  185. <dl class="c function">
  186. <dt class="sig sig-object c" id="c.PyTuple_CheckExact">
  187. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_CheckExact</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_CheckExact" title="Permalink to this definition">¶</a><br /></dt>
  188. <dd><p>Return true if <em>p</em> is a tuple object, but not an instance of a subtype of the
  189. tuple type. This function always succeeds.</p>
  190. </dd></dl>
  191. <dl class="c function">
  192. <dt class="sig sig-object c" id="c.PyTuple_New">
  193. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_New</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">len</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_New" title="Permalink to this definition">¶</a><br /></dt>
  194. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return a new tuple object of size <em>len</em>, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure.</p>
  195. </dd></dl>
  196. <dl class="c function">
  197. <dt class="sig sig-object c" id="c.PyTuple_Pack">
  198. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_Pack</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">n</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_Pack" title="Permalink to this definition">¶</a><br /></dt>
  199. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return a new tuple object of size <em>n</em>, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure. The tuple values
  200. are initialized to the subsequent <em>n</em> C arguments pointing to Python objects.
  201. <code class="docutils literal notranslate"><span class="pre">PyTuple_Pack(2,</span> <span class="pre">a,</span> <span class="pre">b)</span></code> is equivalent to <code class="docutils literal notranslate"><span class="pre">Py_BuildValue(&quot;(OO)&quot;,</span> <span class="pre">a,</span> <span class="pre">b)</span></code>.</p>
  202. </dd></dl>
  203. <dl class="c function">
  204. <dt class="sig sig-object c" id="c.PyTuple_Size">
  205. <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_Size</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_Size" title="Permalink to this definition">¶</a><br /></dt>
  206. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Take a pointer to a tuple object, and return the size of that tuple.</p>
  207. </dd></dl>
  208. <dl class="c function">
  209. <dt class="sig sig-object c" id="c.PyTuple_GET_SIZE">
  210. <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_GET_SIZE</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_GET_SIZE" title="Permalink to this definition">¶</a><br /></dt>
  211. <dd><p>Return the size of the tuple <em>p</em>, which must be non-<code class="docutils literal notranslate"><span class="pre">NULL</span></code> and point to a tuple;
  212. no error checking is performed.</p>
  213. </dd></dl>
  214. <dl class="c function">
  215. <dt class="sig sig-object c" id="c.PyTuple_GetItem">
  216. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_GetItem</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_GetItem" title="Permalink to this definition">¶</a><br /></dt>
  217. <dd><em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the object at position <em>pos</em> in the tuple pointed to by <em>p</em>. If <em>pos</em> is
  218. negative or out of bounds, return <code class="docutils literal notranslate"><span class="pre">NULL</span></code> and set an <a class="reference internal" href="../library/exceptions.html#IndexError" title="IndexError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a> exception.</p>
  219. </dd></dl>
  220. <dl class="c function">
  221. <dt class="sig sig-object c" id="c.PyTuple_GET_ITEM">
  222. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_GET_ITEM</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_GET_ITEM" title="Permalink to this definition">¶</a><br /></dt>
  223. <dd><em class="refcount">Return value: Borrowed reference.</em><p>Like <a class="reference internal" href="#c.PyTuple_GetItem" title="PyTuple_GetItem"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTuple_GetItem()</span></code></a>, but does no checking of its arguments.</p>
  224. </dd></dl>
  225. <dl class="c function">
  226. <dt class="sig sig-object c" id="c.PyTuple_GetSlice">
  227. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_GetSlice</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">low</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">high</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_GetSlice" title="Permalink to this definition">¶</a><br /></dt>
  228. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the slice of the tuple pointed to by <em>p</em> between <em>low</em> and <em>high</em>,
  229. or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on failure. This is the equivalent of the Python expression
  230. <code class="docutils literal notranslate"><span class="pre">p[low:high]</span></code>. Indexing from the end of the tuple is not supported.</p>
  231. </dd></dl>
  232. <dl class="c function">
  233. <dt class="sig sig-object c" id="c.PyTuple_SetItem">
  234. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_SetItem</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">o</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_SetItem" title="Permalink to this definition">¶</a><br /></dt>
  235. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Insert a reference to object <em>o</em> at position <em>pos</em> of the tuple pointed to by
  236. <em>p</em>. Return <code class="docutils literal notranslate"><span class="pre">0</span></code> on success. If <em>pos</em> is out of bounds, return <code class="docutils literal notranslate"><span class="pre">-1</span></code>
  237. and set an <a class="reference internal" href="../library/exceptions.html#IndexError" title="IndexError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a> exception.</p>
  238. <div class="admonition note">
  239. <p class="admonition-title">Note</p>
  240. <p>This function “steals” a reference to <em>o</em> and discards a reference to
  241. an item already in the tuple at the affected position.</p>
  242. </div>
  243. </dd></dl>
  244. <dl class="c function">
  245. <dt class="sig sig-object c" id="c.PyTuple_SET_ITEM">
  246. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyTuple_SET_ITEM</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">o</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyTuple_SET_ITEM" title="Permalink to this definition">¶</a><br /></dt>
  247. <dd><p>Like <a class="reference internal" href="#c.PyTuple_SetItem" title="PyTuple_SetItem"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTuple_SetItem()</span></code></a>, but does no error checking, and should <em>only</em> be
  248. used to fill in brand new tuples.</p>
  249. <div class="admonition note">
  250. <p class="admonition-title">Note</p>
  251. <p>This function “steals” a reference to <em>o</em>, and, unlike
  252. <a class="reference internal" href="#c.PyTuple_SetItem" title="PyTuple_SetItem"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTuple_SetItem()</span></code></a>, does <em>not</em> discard a reference to any item that
  253. is being replaced; any reference in the tuple at position <em>pos</em> will be
  254. leaked.</p>
  255. </div>
  256. </dd></dl>
  257. <dl class="c function">
  258. <dt class="sig sig-object c" id="c._PyTuple_Resize">
  259. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">_PyTuple_Resize</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">newsize</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c._PyTuple_Resize" title="Permalink to this definition">¶</a><br /></dt>
  260. <dd><p>Can be used to resize a tuple. <em>newsize</em> will be the new length of the tuple.
  261. Because tuples are <em>supposed</em> to be immutable, this should only be used if there
  262. is only one reference to the object. Do <em>not</em> use this if the tuple may already
  263. be known to some other part of the code. The tuple will always grow or shrink
  264. at the end. Think of this as destroying the old tuple and creating a new one,
  265. only more efficiently. Returns <code class="docutils literal notranslate"><span class="pre">0</span></code> on success. Client code should never
  266. assume that the resulting value of <code class="docutils literal notranslate"><span class="pre">*p</span></code> will be the same as before calling
  267. this function. If the object referenced by <code class="docutils literal notranslate"><span class="pre">*p</span></code> is replaced, the original
  268. <code class="docutils literal notranslate"><span class="pre">*p</span></code> is destroyed. On failure, returns <code class="docutils literal notranslate"><span class="pre">-1</span></code> and sets <code class="docutils literal notranslate"><span class="pre">*p</span></code> to <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, and
  269. raises <a class="reference internal" href="../library/exceptions.html#MemoryError" title="MemoryError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">MemoryError</span></code></a> or <a class="reference internal" href="../library/exceptions.html#SystemError" title="SystemError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemError</span></code></a>.</p>
  270. </dd></dl>
  271. </section>
  272. <section id="struct-sequence-objects">
  273. <span id="id1"></span><h1>Struct Sequence Objects<a class="headerlink" href="#struct-sequence-objects" title="Permalink to this headline">¶</a></h1>
  274. <p>Struct sequence objects are the C equivalent of <a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a>
  275. objects, i.e. a sequence whose items can also be accessed through attributes.
  276. To create a struct sequence, you first have to create a specific struct sequence
  277. type.</p>
  278. <dl class="c function">
  279. <dt class="sig sig-object c" id="c.PyStructSequence_NewType">
  280. <a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_NewType</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><span class="n"><span class="pre">PyStructSequence_Desc</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">desc</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_NewType" title="Permalink to this definition">¶</a><br /></dt>
  281. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Create a new struct sequence type from the data in <em>desc</em>, described below. Instances
  282. of the resulting type can be created with <a class="reference internal" href="#c.PyStructSequence_New" title="PyStructSequence_New"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStructSequence_New()</span></code></a>.</p>
  283. </dd></dl>
  284. <dl class="c function">
  285. <dt class="sig sig-object c" id="c.PyStructSequence_InitType">
  286. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_InitType</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">type</span></span>, <a class="reference internal" href="#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><span class="n"><span class="pre">PyStructSequence_Desc</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">desc</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_InitType" title="Permalink to this definition">¶</a><br /></dt>
  287. <dd><p>Initializes a struct sequence type <em>type</em> from <em>desc</em> in place.</p>
  288. </dd></dl>
  289. <dl class="c function">
  290. <dt class="sig sig-object c" id="c.PyStructSequence_InitType2">
  291. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_InitType2</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">type</span></span>, <a class="reference internal" href="#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><span class="n"><span class="pre">PyStructSequence_Desc</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">desc</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_InitType2" title="Permalink to this definition">¶</a><br /></dt>
  292. <dd><p>The same as <code class="docutils literal notranslate"><span class="pre">PyStructSequence_InitType</span></code>, but returns <code class="docutils literal notranslate"><span class="pre">0</span></code> on success and <code class="docutils literal notranslate"><span class="pre">-1</span></code> on
  293. failure.</p>
  294. <div class="versionadded">
  295. <p><span class="versionmodified added">New in version 3.4.</span></p>
  296. </div>
  297. </dd></dl>
  298. <dl class="c type">
  299. <dt class="sig sig-object c" id="c.PyStructSequence_Desc">
  300. <span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_Desc</span></span></span><a class="headerlink" href="#c.PyStructSequence_Desc" title="Permalink to this definition">¶</a><br /></dt>
  301. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> (including all members).</em><p>Contains the meta information of a struct sequence type to create.</p>
  302. <dl class="c member">
  303. <dt class="sig sig-object c" id="c.PyStructSequence_Desc.name">
  304. <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">name</span></span></span><a class="headerlink" href="#c.PyStructSequence_Desc.name" title="Permalink to this definition">¶</a><br /></dt>
  305. <dd><p>Name of the struct sequence type.</p>
  306. </dd></dl>
  307. <dl class="c member">
  308. <dt class="sig sig-object c" id="c.PyStructSequence_Desc.doc">
  309. <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">doc</span></span></span><a class="headerlink" href="#c.PyStructSequence_Desc.doc" title="Permalink to this definition">¶</a><br /></dt>
  310. <dd><p>Pointer to docstring for the type or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> to omit.</p>
  311. </dd></dl>
  312. <dl class="c member">
  313. <dt class="sig sig-object c" id="c.PyStructSequence_Desc.fields">
  314. <a class="reference internal" href="#c.PyStructSequence_Field" title="PyStructSequence_Field"><span class="n"><span class="pre">PyStructSequence_Field</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">fields</span></span></span><a class="headerlink" href="#c.PyStructSequence_Desc.fields" title="Permalink to this definition">¶</a><br /></dt>
  315. <dd><p>Pointer to <code class="docutils literal notranslate"><span class="pre">NULL</span></code>-terminated array with field names of the new type.</p>
  316. </dd></dl>
  317. <dl class="c member">
  318. <dt class="sig sig-object c" id="c.PyStructSequence_Desc.n_in_sequence">
  319. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">n_in_sequence</span></span></span><a class="headerlink" href="#c.PyStructSequence_Desc.n_in_sequence" title="Permalink to this definition">¶</a><br /></dt>
  320. <dd><p>Number of fields visible to the Python side (if used as tuple).</p>
  321. </dd></dl>
  322. </dd></dl>
  323. <dl class="c type">
  324. <dt class="sig sig-object c" id="c.PyStructSequence_Field">
  325. <span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_Field</span></span></span><a class="headerlink" href="#c.PyStructSequence_Field" title="Permalink to this definition">¶</a><br /></dt>
  326. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> (including all members).</em><p>Describes a field of a struct sequence. As a struct sequence is modeled as a
  327. tuple, all fields are typed as <span class="c-expr sig sig-inline c"><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n">PyObject</span></a><span class="p">*</span></span>. The index in the
  328. <a class="reference internal" href="#c.PyStructSequence_Desc.fields" title="PyStructSequence_Desc.fields"><code class="xref c c-member docutils literal notranslate"><span class="pre">fields</span></code></a> array of
  329. the <a class="reference internal" href="#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStructSequence_Desc</span></code></a> determines which
  330. field of the struct sequence is described.</p>
  331. <dl class="c member">
  332. <dt class="sig sig-object c" id="c.PyStructSequence_Field.name">
  333. <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">name</span></span></span><a class="headerlink" href="#c.PyStructSequence_Field.name" title="Permalink to this definition">¶</a><br /></dt>
  334. <dd><p>Name for the field or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> to end the list of named fields,
  335. set to <a class="reference internal" href="#c.PyStructSequence_UnnamedField" title="PyStructSequence_UnnamedField"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyStructSequence_UnnamedField</span></code></a> to leave unnamed.</p>
  336. </dd></dl>
  337. <dl class="c member">
  338. <dt class="sig sig-object c" id="c.PyStructSequence_Field.doc">
  339. <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">doc</span></span></span><a class="headerlink" href="#c.PyStructSequence_Field.doc" title="Permalink to this definition">¶</a><br /></dt>
  340. <dd><p>Field docstring or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> to omit.</p>
  341. </dd></dl>
  342. </dd></dl>
  343. <dl class="c var">
  344. <dt class="sig sig-object c" id="c.PyStructSequence_UnnamedField">
  345. <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_UnnamedField</span></span></span><a class="headerlink" href="#c.PyStructSequence_UnnamedField" title="Permalink to this definition">¶</a><br /></dt>
  346. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.11.</em><p>Special value for a field name to leave it unnamed.</p>
  347. <div class="versionchanged">
  348. <p><span class="versionmodified changed">Changed in version 3.9: </span>The type was changed from <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>.</p>
  349. </div>
  350. </dd></dl>
  351. <dl class="c function">
  352. <dt class="sig sig-object c" id="c.PyStructSequence_New">
  353. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_New</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">type</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_New" title="Permalink to this definition">¶</a><br /></dt>
  354. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Creates an instance of <em>type</em>, which must have been created with
  355. <a class="reference internal" href="#c.PyStructSequence_NewType" title="PyStructSequence_NewType"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStructSequence_NewType()</span></code></a>.</p>
  356. </dd></dl>
  357. <dl class="c function">
  358. <dt class="sig sig-object c" id="c.PyStructSequence_GetItem">
  359. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_GetItem</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_GetItem" title="Permalink to this definition">¶</a><br /></dt>
  360. <dd><em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the object at position <em>pos</em> in the struct sequence pointed to by <em>p</em>.
  361. No bounds checking is performed.</p>
  362. </dd></dl>
  363. <dl class="c function">
  364. <dt class="sig sig-object c" id="c.PyStructSequence_GET_ITEM">
  365. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_GET_ITEM</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_GET_ITEM" title="Permalink to this definition">¶</a><br /></dt>
  366. <dd><em class="refcount">Return value: Borrowed reference.</em><p>Macro equivalent of <a class="reference internal" href="#c.PyStructSequence_GetItem" title="PyStructSequence_GetItem"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStructSequence_GetItem()</span></code></a>.</p>
  367. </dd></dl>
  368. <dl class="c function">
  369. <dt class="sig sig-object c" id="c.PyStructSequence_SetItem">
  370. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_SetItem</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pos</span></span>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">o</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_SetItem" title="Permalink to this definition">¶</a><br /></dt>
  371. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Sets the field at index <em>pos</em> of the struct sequence <em>p</em> to value <em>o</em>. Like
  372. <a class="reference internal" href="#c.PyTuple_SET_ITEM" title="PyTuple_SET_ITEM"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTuple_SET_ITEM()</span></code></a>, this should only be used to fill in brand new
  373. instances.</p>
  374. <div class="admonition note">
  375. <p class="admonition-title">Note</p>
  376. <p>This function “steals” a reference to <em>o</em>.</p>
  377. </div>
  378. </dd></dl>
  379. <dl class="c function">
  380. <dt class="sig sig-object c" id="c.PyStructSequence_SET_ITEM">
  381. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyStructSequence_SET_ITEM</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">p</span></span>, <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><span class="n"><span class="pre">Py_ssize_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">pos</span></span>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">o</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStructSequence_SET_ITEM" title="Permalink to this definition">¶</a><br /></dt>
  382. <dd><p>Similar to <a class="reference internal" href="#c.PyStructSequence_SetItem" title="PyStructSequence_SetItem"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStructSequence_SetItem()</span></code></a>, but implemented as a static
  383. inlined function.</p>
  384. <div class="admonition note">
  385. <p class="admonition-title">Note</p>
  386. <p>This function “steals” a reference to <em>o</em>.</p>
  387. </div>
  388. </dd></dl>
  389. </section>
  390. <div class="clearer"></div>
  391. </div>
  392. </div>
  393. </div>
  394. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  395. <div class="sphinxsidebarwrapper">
  396. <div>
  397. <h3><a href="../contents.html">Table of Contents</a></h3>
  398. <ul>
  399. <li><a class="reference internal" href="#">Tuple Objects</a></li>
  400. <li><a class="reference internal" href="#struct-sequence-objects">Struct Sequence Objects</a></li>
  401. </ul>
  402. </div>
  403. <div>
  404. <h4>Previous topic</h4>
  405. <p class="topless"><a href="unicode.html"
  406. title="previous chapter">Unicode Objects and Codecs</a></p>
  407. </div>
  408. <div>
  409. <h4>Next topic</h4>
  410. <p class="topless"><a href="list.html"
  411. title="next chapter">List Objects</a></p>
  412. </div>
  413. <div role="note" aria-label="source link">
  414. <h3>This Page</h3>
  415. <ul class="this-page-menu">
  416. <li><a href="../bugs.html">Report a Bug</a></li>
  417. <li>
  418. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/tuple.rst"
  419. rel="nofollow">Show Source
  420. </a>
  421. </li>
  422. </ul>
  423. </div>
  424. </div>
  425. </div>
  426. <div class="clearer"></div>
  427. </div>
  428. <div class="related" role="navigation" aria-label="related navigation">
  429. <h3>Navigation</h3>
  430. <ul>
  431. <li class="right" style="margin-right: 10px">
  432. <a href="../genindex.html" title="General Index"
  433. >index</a></li>
  434. <li class="right" >
  435. <a href="../py-modindex.html" title="Python Module Index"
  436. >modules</a> |</li>
  437. <li class="right" >
  438. <a href="list.html" title="List Objects"
  439. >next</a> |</li>
  440. <li class="right" >
  441. <a href="unicode.html" title="Unicode Objects and Codecs"
  442. >previous</a> |</li>
  443. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  444. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  445. <li class="switchers">
  446. <div class="language_switcher_placeholder"></div>
  447. <div class="version_switcher_placeholder"></div>
  448. </li>
  449. <li>
  450. </li>
  451. <li id="cpython-language-and-version">
  452. <a href="../index.html">3.12.0 Documentation</a> &#187;
  453. </li>
  454. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  455. <li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> &#187;</li>
  456. <li class="nav-item nav-item-this"><a href="">Tuple Objects</a></li>
  457. <li class="right">
  458. <div class="inline-search" role="search">
  459. <form class="inline-search" action="../search.html" method="get">
  460. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  461. <input type="submit" value="Go" />
  462. </form>
  463. </div>
  464. |
  465. </li>
  466. <li class="right">
  467. <label class="theme-selector-label">
  468. Theme
  469. <select class="theme-selector" oninput="activateTheme(this.value)">
  470. <option value="auto" selected>Auto</option>
  471. <option value="light">Light</option>
  472. <option value="dark">Dark</option>
  473. </select>
  474. </label> |</li>
  475. </ul>
  476. </div>
  477. <div class="footer">
  478. &copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
  479. <br />
  480. This page is licensed under the Python Software Foundation License Version 2.
  481. <br />
  482. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  483. <br />
  484. See <a href="/license.html">History and License</a> for more information.<br />
  485. <br />
  486. The Python Software Foundation is a non-profit corporation.
  487. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  488. <br />
  489. <br />
  490. Last updated on Oct 02, 2023.
  491. <a href="/bugs.html">Found a bug</a>?
  492. <br />
  493. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
  494. </div>
  495. </body>
  496. </html>