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.
26 .. cfunction:: 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 .. cfunction:: 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 .. cfunction:: 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 .. cfunction:: 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 .. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
57 Concat bytearrays *a* and *b* and return a new bytearray with the result.
60 .. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
62 Return the size of *bytearray* after checking for a *NULL* pointer.
65 .. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
67 Return the contents of *bytearray* as a char array after checking for a
71 .. cfunction:: 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 .. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
82 Macro version of :cfunc:`PyByteArray_AsString`.
85 .. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
87 Macro version of :cfunc:`PyByteArray_Size`.