8
.. index:: object: bytearray
13
.. ctype:: PyByteArrayObject
15
This subtype of :ctype:`PyObject` represents a Python bytearray object.
18
.. cvar:: PyTypeObject PyByteArray_Type
20
This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
21
it is the same object as ``bytearray`` in the Python layer.
24
.. cfunction:: int PyByteArray_Check(PyObject *o)
26
Return true if the object *o* is a bytearray object or an instance of a
27
subtype of the bytearray type.
30
.. cfunction:: int PyByteArray_CheckExact(PyObject *o)
32
Return true if the object *o* is a bytearray object, but not an instance of a
33
subtype of the bytearray type.
36
.. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o)
38
Return a new bytearray object from any object, *o*, that implements the
41
.. XXX expand about the buffer protocol, at least somewhere
44
.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
46
Create a new bytearray object from *string* and its length, *len*. On
47
failure, *NULL* is returned.
50
.. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
52
Return the size of *bytearray* after checking for a *NULL* pointer.
55
.. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
57
Macro version of :cfunc:`PyByteArray_Size` that doesn't do pointer checking.
60
.. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
62
Return the contents of *bytearray* as a char array after checking for a
66
.. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
68
Macro version of :cfunc:`PyByteArray_AsString` that doesn't check pointers.
71
.. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
73
Concat bytearrays *a* and *b* and return a new bytearray with the result.
76
.. cfunction:: PyObject* PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
78
Resize the internal buffer of *bytearray* to *len*.