1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>Byte Array Objects — Python 3.5.1 documentation</title>
11
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
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.1 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.1 documentation" href="../contents.html" />
33
<link rel="up" title="Concrete Objects Layer" href="concrete.html" />
34
<link rel="next" title="Unicode Objects and Codecs" href="unicode.html" />
35
<link rel="prev" title="Bytes Objects" href="bytes.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="unicode.html" title="Unicode Objects and Codecs"
55
accesskey="N">next</a> |</li>
57
<a href="bytes.html" title="Bytes Objects"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">3.5.1</span>
64
<a href="../index.html">Documentation </a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
68
<li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="byte-array-objects">
78
<span id="bytearrayobjects"></span><h1>Byte Array Objects<a class="headerlink" href="#byte-array-objects" title="Permalink to this headline">¶</a></h1>
79
<span class="target" id="index-0"></span><dl class="type">
80
<dt id="c.PyByteArrayObject">
81
<code class="descname">PyByteArrayObject</code><a class="headerlink" href="#c.PyByteArrayObject" title="Permalink to this definition">¶</a></dt>
82
<dd><p>This subtype of <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal"><span class="pre">PyObject</span></code></a> represents a Python bytearray object.</p>
86
<dt id="c.PyByteArray_Type">
87
<a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject">PyTypeObject</a> <code class="descname">PyByteArray_Type</code><a class="headerlink" href="#c.PyByteArray_Type" title="Permalink to this definition">¶</a></dt>
88
<dd><p>This instance of <a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><code class="xref c c-type docutils literal"><span class="pre">PyTypeObject</span></code></a> represents the Python bytearray type;
89
it is the same object as <a class="reference internal" href="../library/functions.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal"><span class="pre">bytearray</span></code></a> in the Python layer.</p>
92
<div class="section" id="type-check-macros">
93
<h2>Type check macros<a class="headerlink" href="#type-check-macros" title="Permalink to this headline">¶</a></h2>
95
<dt id="c.PyByteArray_Check">
96
int <code class="descname">PyByteArray_Check</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_Check" title="Permalink to this definition">¶</a></dt>
97
<dd><p>Return true if the object <em>o</em> is a bytearray object or an instance of a
98
subtype of the bytearray type.</p>
101
<dl class="function">
102
<dt id="c.PyByteArray_CheckExact">
103
int <code class="descname">PyByteArray_CheckExact</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_CheckExact" title="Permalink to this definition">¶</a></dt>
104
<dd><p>Return true if the object <em>o</em> is a bytearray object, but not an instance of a
105
subtype of the bytearray type.</p>
109
<div class="section" id="direct-api-functions">
110
<h2>Direct API functions<a class="headerlink" href="#direct-api-functions" title="Permalink to this headline">¶</a></h2>
111
<dl class="function">
112
<dt id="c.PyByteArray_FromObject">
113
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyByteArray_FromObject</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_FromObject" title="Permalink to this definition">¶</a></dt>
114
<dd><p>Return a new bytearray object from any object, <em>o</em>, that implements the
115
<a class="reference internal" href="buffer.html#bufferobjects"><span>buffer protocol</span></a>.</p>
118
<dl class="function">
119
<dt id="c.PyByteArray_FromStringAndSize">
120
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyByteArray_FromStringAndSize</code><span class="sig-paren">(</span>const char<em> *string</em>, Py_ssize_t<em> len</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_FromStringAndSize" title="Permalink to this definition">¶</a></dt>
121
<dd><p>Create a new bytearray object from <em>string</em> and its length, <em>len</em>. On
122
failure, <em>NULL</em> is returned.</p>
125
<dl class="function">
126
<dt id="c.PyByteArray_Concat">
127
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyByteArray_Concat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *a</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *b</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_Concat" title="Permalink to this definition">¶</a></dt>
128
<dd><p>Concat bytearrays <em>a</em> and <em>b</em> and return a new bytearray with the result.</p>
131
<dl class="function">
132
<dt id="c.PyByteArray_Size">
133
Py_ssize_t <code class="descname">PyByteArray_Size</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *bytearray</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_Size" title="Permalink to this definition">¶</a></dt>
134
<dd><p>Return the size of <em>bytearray</em> after checking for a <em>NULL</em> pointer.</p>
137
<dl class="function">
138
<dt id="c.PyByteArray_AsString">
139
char* <code class="descname">PyByteArray_AsString</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *bytearray</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_AsString" title="Permalink to this definition">¶</a></dt>
140
<dd><p>Return the contents of <em>bytearray</em> as a char array after checking for a
141
<em>NULL</em> pointer. The returned array always has an extra
142
null byte appended.</p>
145
<dl class="function">
146
<dt id="c.PyByteArray_Resize">
147
int <code class="descname">PyByteArray_Resize</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *bytearray</em>, Py_ssize_t<em> len</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_Resize" title="Permalink to this definition">¶</a></dt>
148
<dd><p>Resize the internal buffer of <em>bytearray</em> to <em>len</em>.</p>
152
<div class="section" id="macros">
153
<h2>Macros<a class="headerlink" href="#macros" title="Permalink to this headline">¶</a></h2>
154
<p>These macros trade safety for speed and they don’t check pointers.</p>
155
<dl class="function">
156
<dt id="c.PyByteArray_AS_STRING">
157
char* <code class="descname">PyByteArray_AS_STRING</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *bytearray</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_AS_STRING" title="Permalink to this definition">¶</a></dt>
158
<dd><p>Macro version of <a class="reference internal" href="#c.PyByteArray_AsString" title="PyByteArray_AsString"><code class="xref c c-func docutils literal"><span class="pre">PyByteArray_AsString()</span></code></a>.</p>
161
<dl class="function">
162
<dt id="c.PyByteArray_GET_SIZE">
163
Py_ssize_t <code class="descname">PyByteArray_GET_SIZE</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *bytearray</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyByteArray_GET_SIZE" title="Permalink to this definition">¶</a></dt>
164
<dd><p>Macro version of <a class="reference internal" href="#c.PyByteArray_Size" title="PyByteArray_Size"><code class="xref c c-func docutils literal"><span class="pre">PyByteArray_Size()</span></code></a>.</p>
174
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
175
<div class="sphinxsidebarwrapper">
176
<h3><a href="../contents.html">Table Of Contents</a></h3>
178
<li><a class="reference internal" href="#">Byte Array Objects</a><ul>
179
<li><a class="reference internal" href="#type-check-macros">Type check macros</a></li>
180
<li><a class="reference internal" href="#direct-api-functions">Direct API functions</a></li>
181
<li><a class="reference internal" href="#macros">Macros</a></li>
186
<h4>Previous topic</h4>
187
<p class="topless"><a href="bytes.html"
188
title="previous chapter">Bytes Objects</a></p>
190
<p class="topless"><a href="unicode.html"
191
title="next chapter">Unicode Objects and Codecs</a></p>
193
<ul class="this-page-menu">
194
<li><a href="../bugs.html">Report a Bug</a></li>
195
<li><a href="../_sources/c-api/bytearray.txt"
196
rel="nofollow">Show Source</a></li>
199
<div id="searchbox" style="display: none" role="search">
200
<h3>Quick search</h3>
201
<form class="search" action="../search.html" method="get">
202
<input type="text" name="q" />
203
<input type="submit" value="Go" />
204
<input type="hidden" name="check_keywords" value="yes" />
205
<input type="hidden" name="area" value="default" />
207
<p class="searchtip" style="font-size: 90%">
208
Enter search terms or a module, class or function name.
211
<script type="text/javascript">$('#searchbox').show(0);</script>
214
<div class="clearer"></div>
216
<div class="related" role="navigation" aria-label="related navigation">
219
<li class="right" style="margin-right: 10px">
220
<a href="../genindex.html" title="General Index"
223
<a href="../py-modindex.html" title="Python Module Index"
226
<a href="unicode.html" title="Unicode Objects and Codecs"
229
<a href="bytes.html" title="Bytes Objects"
231
<li><img src="../_static/py.png" alt=""
232
style="vertical-align: middle; margin-top: -1px"/></li>
233
<li><a href="https://www.python.org/">Python</a> »</li>
235
<span class="version_switcher_placeholder">3.5.1</span>
236
<a href="../index.html">Documentation </a> »
239
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
240
<li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> »</li>
244
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
246
The Python Software Foundation is a non-profit corporation.
247
<a href="https://www.python.org/psf/donations/">Please donate.</a>
249
Last updated on Jan 22, 2016.
250
<a href="../bugs.html">Found a bug</a>?
252
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'