blob: 1b0f3776aa8f6b2e0cb66144fa282b8294d44000 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001.. highlightlang:: c
2
3.. _bytearrayobjects:
4
5Byte Array Objects
6------------------
7
8.. index:: object: bytearray
9
10
11.. ctype:: PyByteArrayObject
12
13 This subtype of :ctype:`PyObject` represents a Python string object.
14
15
16.. cvar:: PyTypeObject PyByteArray_Type
17
18 This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
19 it is the same object as ``bytearray`` in the Python layer.
20
21
22.. cfunction:: int PyByteArray_Check(PyObject *o)
23
24 Return true if the object *o* is a bytearray object or an instance of a
25 subtype of the bytearray type.
26
27
28.. cfunction:: int PyByteArray_CheckExact(PyObject *o)
29
30 Return true if the object *o* is a bytearray object, but not an instance of a
31 subtype of the bytearray type.
32
33
34.. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o)
35
36 Return a new bytearray object from any object, *o*, that implements the
37 buffer protocol.
38
39
40.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
41
42 Create a new bytearray object from *string* and it's length, *len*. On
43 failure, *NULL* is returned.
44
45
46.. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
47
48 Return the size of *bytearray* after checking for a *NULL* pointer.
49
50
51.. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
52
53 Macro version of :cfunc:`PyByteArray_Size` that doesn't do pointer checking.
54
55
56.. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
57
58 Return the contents of *bytearray* as a char array after checking for a
59 *NULL* pointer.
60
61
62.. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
63
64 Macro version of :cfunc:`PyByteArray_AsString` that doesn't check pointers.
65
66
67.. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
68
69 Concat bytearrays *a* and *b* and return a new bytearray with the result.
70
71
72.. cfunction:: PyObject* PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
73
74 Resize the internal buffer of *bytearray* to *len*.