Byte Array Objects¶
- PyTypeObjectPyByteArray_Type¶
- Part of theStable ABI.
This instance of
PyTypeObject
represents the Python bytearray type;it is the same object asbytearray
in the Python layer.
Type check macros¶
Direct API functions¶
- PyObject*PyByteArray_FromObject(PyObject*o)¶
- Return value: New reference. Part of theStable ABI.
Return a new bytearray object from any object,o, that implements thebuffer protocol.
On failure, return
NULL
with an exception set.
- PyObject*PyByteArray_FromStringAndSize(constchar*string,Py_ssize_tlen)¶
- Return value: New reference. Part of theStable ABI.
Create a new bytearray object fromstring and its length,len.
On failure, return
NULL
with an exception set.
- PyObject*PyByteArray_Concat(PyObject*a,PyObject*b)¶
- Return value: New reference. Part of theStable ABI.
Concat bytearraysa andb and return a new bytearray with the result.
On failure, return
NULL
with an exception set.
- Py_ssize_tPyByteArray_Size(PyObject*bytearray)¶
- Part of theStable ABI.
Return the size ofbytearray after checking for a
NULL
pointer.
- char*PyByteArray_AsString(PyObject*bytearray)¶
- Part of theStable ABI.
Return the contents ofbytearray as a char array after checking for a
NULL
pointer. The returned array always has an extranull byte appended.
- intPyByteArray_Resize(PyObject*bytearray,Py_ssize_tlen)¶
- Part of theStable ABI.
Resize the internal buffer ofbytearray tolen.
Macros¶
These macros trade safety for speed and they don’t check pointers.
- char*PyByteArray_AS_STRING(PyObject*bytearray)¶
Similar to
PyByteArray_AsString()
, but without error checking.
- Py_ssize_tPyByteArray_GET_SIZE(PyObject*bytearray)¶
Similar to
PyByteArray_Size()
, but without error checking.