8
.. index:: object: bytearray
13
.. c:type:: PyByteArrayObject
15
This subtype of :c:type:`PyObject` represents a Python bytearray object.
18
.. c:var:: PyTypeObject PyByteArray_Type
20
This instance of :c:type:`PyTypeObject` represents the Python bytearray type;
21
it is the same object as ``bytearray`` in the Python layer.
26
.. c:function:: int PyByteArray_Check(PyObject *o)
28
Return true if the object *o* is a bytearray object or an instance of a
29
subtype of the bytearray type.
32
.. c:function:: int PyByteArray_CheckExact(PyObject *o)
34
Return true if the object *o* is a bytearray object, but not an instance of a
35
subtype of the bytearray type.
41
.. c:function:: PyObject* PyByteArray_FromObject(PyObject *o)
43
Return a new bytearray object from any object, *o*, that implements the
46
.. XXX expand about the buffer protocol, at least somewhere
49
.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
51
Create a new bytearray object from *string* and its length, *len*. On
52
failure, *NULL* is returned.
55
.. c:function:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
57
Concat bytearrays *a* and *b* and return a new bytearray with the result.
60
.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
62
Return the size of *bytearray* after checking for a *NULL* pointer.
65
.. c:function:: char* PyByteArray_AsString(PyObject *bytearray)
67
Return the contents of *bytearray* as a char array after checking for a
71
.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
73
Resize the internal buffer of *bytearray* to *len*.
78
These macros trade safety for speed and they don't check pointers.
80
.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray)
82
Macro version of :c:func:`PyByteArray_AsString`.
85
.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
87
Macro version of :c:func:`PyByteArray_Size`.