Byte Array Objects¶
- PyTypeObjectPyByteArray_Type¶
- Μέρος τουΣταθερό 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)¶
- Επιστρεφόμενη τιμή: New reference. Μέρος τουΣταθερό 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)¶
- Επιστρεφόμενη τιμή: New reference. Μέρος τουΣταθερό 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)¶
- Επιστρεφόμενη τιμή: New reference. Μέρος τουΣταθερό 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)¶
- Μέρος τουΣταθερό ABI.
Return the size ofbytearray after checking for a
NULL
pointer.
- char*PyByteArray_AsString(PyObject*bytearray)¶
- Μέρος τουΣταθερό 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)¶
- Μέρος τουΣταθερό ABI.
Resize the internal buffer ofbytearray tolen.Failure is a
-1
return with an exception set.Άλλαξε στην έκδοση 3.14:A negativelen will now result in an exception being set and -1 returned.
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.