~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-3.5.2-docs-html/c-api/sequence.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>Sequence Protocol &mdash; Python 3.5.2 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '3.5.2',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 3.5.2 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 3.5.2 documentation" href="../contents.html" />
 
33
    <link rel="up" title="Abstract Objects Layer" href="abstract.html" />
 
34
    <link rel="next" title="Mapping Protocol" href="mapping.html" />
 
35
    <link rel="prev" title="Number Protocol" href="number.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    
 
38
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
39
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
40
    
 
41
    
 
42
 
 
43
 
 
44
  </head>
 
45
  <body role="document">  
 
46
    <div class="related" role="navigation" aria-label="related navigation">
 
47
      <h3>Navigation</h3>
 
48
      <ul>
 
49
        <li class="right" style="margin-right: 10px">
 
50
          <a href="../genindex.html" title="General Index"
 
51
             accesskey="I">index</a></li>
 
52
        <li class="right" >
 
53
          <a href="../py-modindex.html" title="Python Module Index"
 
54
             >modules</a> |</li>
 
55
        <li class="right" >
 
56
          <a href="mapping.html" title="Mapping Protocol"
 
57
             accesskey="N">next</a> |</li>
 
58
        <li class="right" >
 
59
          <a href="number.html" title="Number Protocol"
 
60
             accesskey="P">previous</a> |</li>
 
61
        <li><img src="../_static/py.png" alt=""
 
62
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
63
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
64
        <li>
 
65
          <span class="version_switcher_placeholder">3.5.2</span>
 
66
          <a href="../index.html">Documentation </a> &raquo;
 
67
        </li>
 
68
 
 
69
          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &raquo;</li>
 
70
          <li class="nav-item nav-item-2"><a href="abstract.html" accesskey="U">Abstract Objects Layer</a> &raquo;</li>
 
71
    <li class="right">
 
72
        
 
73
 
 
74
    <div class="inline-search" style="display: none" role="search">
 
75
        <form class="inline-search" action="../search.html" method="get">
 
76
          <input placeholder="Quick search" type="text" name="q" />
 
77
          <input type="submit" value="Go" />
 
78
          <input type="hidden" name="check_keywords" value="yes" />
 
79
          <input type="hidden" name="area" value="default" />
 
80
        </form>
 
81
    </div>
 
82
    <script type="text/javascript">$('.inline-search').show(0);</script>
 
83
         |
 
84
    </li>
 
85
 
 
86
      </ul>
 
87
    </div>    
 
88
 
 
89
    <div class="document">
 
90
      <div class="documentwrapper">
 
91
        <div class="bodywrapper">
 
92
          <div class="body" role="main">
 
93
            
 
94
  <div class="section" id="sequence-protocol">
 
95
<span id="sequence"></span><h1>Sequence Protocol<a class="headerlink" href="#sequence-protocol" title="Permalink to this headline">¶</a></h1>
 
96
<dl class="function">
 
97
<dt id="c.PySequence_Check">
 
98
int <code class="descname">PySequence_Check</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Check" title="Permalink to this definition">¶</a></dt>
 
99
<dd><p>Return <code class="docutils literal"><span class="pre">1</span></code> if the object provides sequence protocol, and <code class="docutils literal"><span class="pre">0</span></code> otherwise.
 
100
This function always succeeds.</p>
 
101
</dd></dl>
 
102
 
 
103
<dl class="function">
 
104
<dt id="c.PySequence_Size">
 
105
Py_ssize_t <code class="descname">PySequence_Size</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Size" title="Permalink to this definition">¶</a></dt>
 
106
<dt id="c.PySequence_Length">
 
107
Py_ssize_t <code class="descname">PySequence_Length</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Length" title="Permalink to this definition">¶</a></dt>
 
108
<dd><p id="index-0">Returns the number of objects in sequence <em>o</em> on success, and <code class="docutils literal"><span class="pre">-1</span></code> on failure.
 
109
For objects that do not provide sequence protocol, this is equivalent to the
 
110
Python expression <code class="docutils literal"><span class="pre">len(o)</span></code>.</p>
 
111
</dd></dl>
 
112
 
 
113
<dl class="function">
 
114
<dt id="c.PySequence_Concat">
 
115
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_Concat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o1</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o2</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Concat" title="Permalink to this definition">¶</a></dt>
 
116
<dd><em class="refcount">Return value: New reference.</em><p>Return the concatenation of <em>o1</em> and <em>o2</em> on success, and <em>NULL</em> on failure.
 
117
This is the equivalent of the Python expression <code class="docutils literal"><span class="pre">o1</span> <span class="pre">+</span> <span class="pre">o2</span></code>.</p>
 
118
</dd></dl>
 
119
 
 
120
<dl class="function">
 
121
<dt id="c.PySequence_Repeat">
 
122
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_Repeat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;count</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Repeat" title="Permalink to this definition">¶</a></dt>
 
123
<dd><em class="refcount">Return value: New reference.</em><p>Return the result of repeating sequence object <em>o</em> <em>count</em> times, or <em>NULL</em> on
 
124
failure.  This is the equivalent of the Python expression <code class="docutils literal"><span class="pre">o</span> <span class="pre">*</span> <span class="pre">count</span></code>.</p>
 
125
</dd></dl>
 
126
 
 
127
<dl class="function">
 
128
<dt id="c.PySequence_InPlaceConcat">
 
129
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_InPlaceConcat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o1</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o2</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_InPlaceConcat" title="Permalink to this definition">¶</a></dt>
 
130
<dd><em class="refcount">Return value: New reference.</em><p>Return the concatenation of <em>o1</em> and <em>o2</em> on success, and <em>NULL</em> on failure.
 
131
The operation is done <em>in-place</em> when <em>o1</em> supports it.  This is the equivalent
 
132
of the Python expression <code class="docutils literal"><span class="pre">o1</span> <span class="pre">+=</span> <span class="pre">o2</span></code>.</p>
 
133
</dd></dl>
 
134
 
 
135
<dl class="function">
 
136
<dt id="c.PySequence_InPlaceRepeat">
 
137
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_InPlaceRepeat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;count</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_InPlaceRepeat" title="Permalink to this definition">¶</a></dt>
 
138
<dd><em class="refcount">Return value: New reference.</em><p>Return the result of repeating sequence object <em>o</em> <em>count</em> times, or <em>NULL</em> on
 
139
failure.  The operation is done <em>in-place</em> when <em>o</em> supports it.  This is the
 
140
equivalent of the Python expression <code class="docutils literal"><span class="pre">o</span> <span class="pre">*=</span> <span class="pre">count</span></code>.</p>
 
141
</dd></dl>
 
142
 
 
143
<dl class="function">
 
144
<dt id="c.PySequence_GetItem">
 
145
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_GetItem</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_GetItem" title="Permalink to this definition">¶</a></dt>
 
146
<dd><em class="refcount">Return value: New reference.</em><p>Return the <em>i</em>th element of <em>o</em>, or <em>NULL</em> on failure. This is the equivalent of
 
147
the Python expression <code class="docutils literal"><span class="pre">o[i]</span></code>.</p>
 
148
</dd></dl>
 
149
 
 
150
<dl class="function">
 
151
<dt id="c.PySequence_GetSlice">
 
152
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_GetSlice</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i1</em>, Py_ssize_t<em>&nbsp;i2</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_GetSlice" title="Permalink to this definition">¶</a></dt>
 
153
<dd><em class="refcount">Return value: New reference.</em><p>Return the slice of sequence object <em>o</em> between <em>i1</em> and <em>i2</em>, or <em>NULL</em> on
 
154
failure. This is the equivalent of the Python expression <code class="docutils literal"><span class="pre">o[i1:i2]</span></code>.</p>
 
155
</dd></dl>
 
156
 
 
157
<dl class="function">
 
158
<dt id="c.PySequence_SetItem">
 
159
int <code class="descname">PySequence_SetItem</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*v</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_SetItem" title="Permalink to this definition">¶</a></dt>
 
160
<dd><p>Assign object <em>v</em> to the <em>i</em>th element of <em>o</em>.  Raise an exception
 
161
and return <code class="docutils literal"><span class="pre">-1</span></code> on failure; return <code class="docutils literal"><span class="pre">0</span></code> on success.  This
 
162
is the equivalent of the Python statement <code class="docutils literal"><span class="pre">o[i]</span> <span class="pre">=</span> <span class="pre">v</span></code>.  This function <em>does
 
163
not</em> steal a reference to <em>v</em>.</p>
 
164
<p>If <em>v</em> is <em>NULL</em>, the element is deleted, however this feature is
 
165
deprecated in favour of using <a class="reference internal" href="#c.PySequence_DelItem" title="PySequence_DelItem"><code class="xref c c-func docutils literal"><span class="pre">PySequence_DelItem()</span></code></a>.</p>
 
166
</dd></dl>
 
167
 
 
168
<dl class="function">
 
169
<dt id="c.PySequence_DelItem">
 
170
int <code class="descname">PySequence_DelItem</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_DelItem" title="Permalink to this definition">¶</a></dt>
 
171
<dd><p>Delete the <em>i</em>th element of object <em>o</em>.  Returns <code class="docutils literal"><span class="pre">-1</span></code> on failure.  This is the
 
172
equivalent of the Python statement <code class="docutils literal"><span class="pre">del</span> <span class="pre">o[i]</span></code>.</p>
 
173
</dd></dl>
 
174
 
 
175
<dl class="function">
 
176
<dt id="c.PySequence_SetSlice">
 
177
int <code class="descname">PySequence_SetSlice</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i1</em>, Py_ssize_t<em>&nbsp;i2</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*v</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_SetSlice" title="Permalink to this definition">¶</a></dt>
 
178
<dd><p>Assign the sequence object <em>v</em> to the slice in sequence object <em>o</em> from <em>i1</em> to
 
179
<em>i2</em>.  This is the equivalent of the Python statement <code class="docutils literal"><span class="pre">o[i1:i2]</span> <span class="pre">=</span> <span class="pre">v</span></code>.</p>
 
180
</dd></dl>
 
181
 
 
182
<dl class="function">
 
183
<dt id="c.PySequence_DelSlice">
 
184
int <code class="descname">PySequence_DelSlice</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i1</em>, Py_ssize_t<em>&nbsp;i2</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_DelSlice" title="Permalink to this definition">¶</a></dt>
 
185
<dd><p>Delete the slice in sequence object <em>o</em> from <em>i1</em> to <em>i2</em>.  Returns <code class="docutils literal"><span class="pre">-1</span></code> on
 
186
failure.  This is the equivalent of the Python statement <code class="docutils literal"><span class="pre">del</span> <span class="pre">o[i1:i2]</span></code>.</p>
 
187
</dd></dl>
 
188
 
 
189
<dl class="function">
 
190
<dt id="c.PySequence_Count">
 
191
Py_ssize_t <code class="descname">PySequence_Count</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Count" title="Permalink to this definition">¶</a></dt>
 
192
<dd><p>Return the number of occurrences of <em>value</em> in <em>o</em>, that is, return the number
 
193
of keys for which <code class="docutils literal"><span class="pre">o[key]</span> <span class="pre">==</span> <span class="pre">value</span></code>.  On failure, return <code class="docutils literal"><span class="pre">-1</span></code>.  This is
 
194
equivalent to the Python expression <code class="docutils literal"><span class="pre">o.count(value)</span></code>.</p>
 
195
</dd></dl>
 
196
 
 
197
<dl class="function">
 
198
<dt id="c.PySequence_Contains">
 
199
int <code class="descname">PySequence_Contains</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Contains" title="Permalink to this definition">¶</a></dt>
 
200
<dd><p>Determine if <em>o</em> contains <em>value</em>.  If an item in <em>o</em> is equal to <em>value</em>,
 
201
return <code class="docutils literal"><span class="pre">1</span></code>, otherwise return <code class="docutils literal"><span class="pre">0</span></code>. On error, return <code class="docutils literal"><span class="pre">-1</span></code>.  This is
 
202
equivalent to the Python expression <code class="docutils literal"><span class="pre">value</span> <span class="pre">in</span> <span class="pre">o</span></code>.</p>
 
203
</dd></dl>
 
204
 
 
205
<dl class="function">
 
206
<dt id="c.PySequence_Index">
 
207
Py_ssize_t <code class="descname">PySequence_Index</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Index" title="Permalink to this definition">¶</a></dt>
 
208
<dd><p>Return the first index <em>i</em> for which <code class="docutils literal"><span class="pre">o[i]</span> <span class="pre">==</span> <span class="pre">value</span></code>.  On error, return
 
209
<code class="docutils literal"><span class="pre">-1</span></code>.    This is equivalent to the Python expression <code class="docutils literal"><span class="pre">o.index(value)</span></code>.</p>
 
210
</dd></dl>
 
211
 
 
212
<dl class="function">
 
213
<dt id="c.PySequence_List">
 
214
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_List</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_List" title="Permalink to this definition">¶</a></dt>
 
215
<dd><em class="refcount">Return value: New reference.</em><p>Return a list object with the same contents as the sequence or iterable <em>o</em>,
 
216
or <em>NULL</em> on failure.  The returned list is guaranteed to be new.  This is
 
217
equivalent to the Python expression <code class="docutils literal"><span class="pre">list(o)</span></code>.</p>
 
218
</dd></dl>
 
219
 
 
220
<dl class="function">
 
221
<dt id="c.PySequence_Tuple">
 
222
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_Tuple</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Tuple" title="Permalink to this definition">¶</a></dt>
 
223
<dd><em class="refcount">Return value: New reference.</em><p id="index-1">Return a tuple object with the same contents as the arbitrary sequence <em>o</em> or
 
224
<em>NULL</em> on failure.  If <em>o</em> is a tuple, a new reference will be returned,
 
225
otherwise a tuple will be constructed with the appropriate contents.  This is
 
226
equivalent to the Python expression <code class="docutils literal"><span class="pre">tuple(o)</span></code>.</p>
 
227
</dd></dl>
 
228
 
 
229
<dl class="function">
 
230
<dt id="c.PySequence_Fast">
 
231
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_Fast</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, const char<em>&nbsp;*m</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Fast" title="Permalink to this definition">¶</a></dt>
 
232
<dd><em class="refcount">Return value: New reference.</em><p>Return the sequence <em>o</em> as a list, unless it is already a tuple or list, in
 
233
which case <em>o</em> is returned.  Use <a class="reference internal" href="#c.PySequence_Fast_GET_ITEM" title="PySequence_Fast_GET_ITEM"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Fast_GET_ITEM()</span></code></a> to access
 
234
the members of the result.  Returns <em>NULL</em> on failure.  If the object is not
 
235
a sequence, raises <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal"><span class="pre">TypeError</span></code></a> with <em>m</em> as the message text.</p>
 
236
</dd></dl>
 
237
 
 
238
<dl class="function">
 
239
<dt id="c.PySequence_Fast_GET_ITEM">
 
240
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_Fast_GET_ITEM</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Fast_GET_ITEM" title="Permalink to this definition">¶</a></dt>
 
241
<dd><em class="refcount">Return value: Borrowed reference.</em><p>Return the <em>i</em>th element of <em>o</em>, assuming that <em>o</em> was returned by
 
242
<a class="reference internal" href="#c.PySequence_Fast" title="PySequence_Fast"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Fast()</span></code></a>, <em>o</em> is not <em>NULL</em>, and that <em>i</em> is within bounds.</p>
 
243
</dd></dl>
 
244
 
 
245
<dl class="function">
 
246
<dt id="c.PySequence_Fast_ITEMS">
 
247
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>** <code class="descname">PySequence_Fast_ITEMS</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Fast_ITEMS" title="Permalink to this definition">¶</a></dt>
 
248
<dd><p>Return the underlying array of PyObject pointers.  Assumes that <em>o</em> was returned
 
249
by <a class="reference internal" href="#c.PySequence_Fast" title="PySequence_Fast"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Fast()</span></code></a> and <em>o</em> is not <em>NULL</em>.</p>
 
250
<p>Note, if a list gets resized, the reallocation may relocate the items array.
 
251
So, only use the underlying array pointer in contexts where the sequence
 
252
cannot change.</p>
 
253
</dd></dl>
 
254
 
 
255
<dl class="function">
 
256
<dt id="c.PySequence_ITEM">
 
257
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PySequence_ITEM</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em>, Py_ssize_t<em>&nbsp;i</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_ITEM" title="Permalink to this definition">¶</a></dt>
 
258
<dd><em class="refcount">Return value: New reference.</em><p>Return the <em>i</em>th element of <em>o</em> or <em>NULL</em> on failure. Macro form of
 
259
<a class="reference internal" href="#c.PySequence_GetItem" title="PySequence_GetItem"><code class="xref c c-func docutils literal"><span class="pre">PySequence_GetItem()</span></code></a> but without checking that
 
260
<a class="reference internal" href="#c.PySequence_Check" title="PySequence_Check"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Check()</span></code></a> on <em>o</em> is true and without adjustment for negative
 
261
indices.</p>
 
262
</dd></dl>
 
263
 
 
264
<dl class="function">
 
265
<dt id="c.PySequence_Fast_GET_SIZE">
 
266
Py_ssize_t <code class="descname">PySequence_Fast_GET_SIZE</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em>&nbsp;*o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PySequence_Fast_GET_SIZE" title="Permalink to this definition">¶</a></dt>
 
267
<dd><p>Returns the length of <em>o</em>, assuming that <em>o</em> was returned by
 
268
<a class="reference internal" href="#c.PySequence_Fast" title="PySequence_Fast"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Fast()</span></code></a> and that <em>o</em> is not <em>NULL</em>.  The size can also be
 
269
gotten by calling <a class="reference internal" href="#c.PySequence_Size" title="PySequence_Size"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Size()</span></code></a> on <em>o</em>, but
 
270
<a class="reference internal" href="#c.PySequence_Fast_GET_SIZE" title="PySequence_Fast_GET_SIZE"><code class="xref c c-func docutils literal"><span class="pre">PySequence_Fast_GET_SIZE()</span></code></a> is faster because it can assume <em>o</em> is a list
 
271
or tuple.</p>
 
272
</dd></dl>
 
273
 
 
274
</div>
 
275
 
 
276
 
 
277
          </div>
 
278
        </div>
 
279
      </div>
 
280
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
281
        <div class="sphinxsidebarwrapper">
 
282
  <h4>Previous topic</h4>
 
283
  <p class="topless"><a href="number.html"
 
284
                        title="previous chapter">Number Protocol</a></p>
 
285
  <h4>Next topic</h4>
 
286
  <p class="topless"><a href="mapping.html"
 
287
                        title="next chapter">Mapping Protocol</a></p>
 
288
  <div role="note" aria-label="source link">
 
289
    <h3>This Page</h3>
 
290
    <ul class="this-page-menu">
 
291
      <li><a href="../bugs.html">Report a Bug</a></li>
 
292
      <li><a href="../_sources/c-api/sequence.txt"
 
293
            rel="nofollow">Show Source</a></li>
 
294
    </ul>
 
295
  </div>
 
296
        </div>
 
297
      </div>
 
298
      <div class="clearer"></div>
 
299
    </div>  
 
300
    <div class="related" role="navigation" aria-label="related navigation">
 
301
      <h3>Navigation</h3>
 
302
      <ul>
 
303
        <li class="right" style="margin-right: 10px">
 
304
          <a href="../genindex.html" title="General Index"
 
305
             >index</a></li>
 
306
        <li class="right" >
 
307
          <a href="../py-modindex.html" title="Python Module Index"
 
308
             >modules</a> |</li>
 
309
        <li class="right" >
 
310
          <a href="mapping.html" title="Mapping Protocol"
 
311
             >next</a> |</li>
 
312
        <li class="right" >
 
313
          <a href="number.html" title="Number Protocol"
 
314
             >previous</a> |</li>
 
315
        <li><img src="../_static/py.png" alt=""
 
316
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
317
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
318
        <li>
 
319
          <span class="version_switcher_placeholder">3.5.2</span>
 
320
          <a href="../index.html">Documentation </a> &raquo;
 
321
        </li>
 
322
 
 
323
          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &raquo;</li>
 
324
          <li class="nav-item nav-item-2"><a href="abstract.html" >Abstract Objects Layer</a> &raquo;</li>
 
325
    <li class="right">
 
326
        
 
327
 
 
328
    <div class="inline-search" style="display: none" role="search">
 
329
        <form class="inline-search" action="../search.html" method="get">
 
330
          <input placeholder="Quick search" type="text" name="q" />
 
331
          <input type="submit" value="Go" />
 
332
          <input type="hidden" name="check_keywords" value="yes" />
 
333
          <input type="hidden" name="area" value="default" />
 
334
        </form>
 
335
    </div>
 
336
    <script type="text/javascript">$('.inline-search').show(0);</script>
 
337
         |
 
338
    </li>
 
339
 
 
340
      </ul>
 
341
    </div>  
 
342
    <div class="footer">
 
343
    &copy; <a href="../copyright.html">Copyright</a> 2001-2016, Python Software Foundation.
 
344
    <br />
 
345
    The Python Software Foundation is a non-profit corporation.
 
346
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
347
    <br />
 
348
    Last updated on Sep 23, 2016.
 
349
    <a href="../bugs.html">Found a bug</a>?
 
350
    <br />
 
351
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
352
    </div>
 
353
 
 
354
  </body>
 
355
</html>
 
 
b'\\ No newline at end of file'