Objek Byte Array¶
-
PyTypeObject PyByteArray_Type¶
- Part of the Stable ABI.
Instance dari
PyTypeObjectmewakili tipe bytearray Python; itu adalah objek yang sama denganbytearraydi lapisan Python.
Makro cek tipe¶
Fungsi API langsung¶
-
PyObject *PyByteArray_FromObject(PyObject *o)¶
- Return value: New reference. Part of the Stable ABI. Thread safety: Safe for concurrent use on the same object.
Mengembalikan objek bytearray baru dari objek apa pun, o, yang mengimplementasikan buffer protocol.
On failure, return
NULLwith an exception set.Catatan
If the object implements the buffer protocol, then the buffer must not be mutated while the bytearray object is being created.
-
PyObject *PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)¶
- Return value: New reference. Part of the Stable ABI. Thread safety: Atomic.
Create a new bytearray object from string and its length, len.
On failure, return
NULLwith an exception set.
-
PyObject *PyByteArray_Concat(PyObject *a, PyObject *b)¶
- Return value: New reference. Part of the Stable ABI. Thread safety: Safe for concurrent use on the same object.
Menyatukan bytearrays a dan b dan mengembalikan bytearray baru dengan hasilnya.
On failure, return
NULLwith an exception set.Catatan
If the object implements the buffer protocol, then the buffer must not be mutated while the bytearray object is being created.
-
Py_ssize_t PyByteArray_Size(PyObject *bytearray)¶
- Part of the Stable ABI. Thread safety: Atomic.
Mengembalikan ukuran bytearray setelah memeriksa pointer
NULL.
-
char *PyByteArray_AsString(PyObject *bytearray)¶
- Part of the Stable ABI. Thread safety: Safe to call from multiple threads with external synchronization only.
Mengembalikan konten bytearray sebagai array karakter setelah memeriksa pointer
NULL. Array yang dikembalikan selalu memiliki byte null ekstra yang ditambahkan.Catatan
It is not thread-safe to mutate the bytearray object while using the returned char array.
-
int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)¶
- Part of the Stable ABI.
Resize the internal buffer of bytearray to len. Failure is a
-1return with an exception set.Berubah pada versi 3.14: A negative len will now result in an exception being set and -1 returned.
Makro¶
Makro ini menukar keamanan dengan kecepatan dan tidak memeriksa pointer.
-
char *PyByteArray_AS_STRING(PyObject *bytearray)¶
- Thread safety: Safe to call from multiple threads with external synchronization only.
Similar to
PyByteArray_AsString(), but without error checking.Catatan
It is not thread-safe to mutate the bytearray object while using the returned char array.
-
Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)¶
- Thread safety: Atomic.
Similar to
PyByteArray_Size(), but without error checking.