bytearray オブジェクト¶
-
PyTypeObject PyByteArray_Type¶
- 次に属します: Stable ABI.
この
PyTypeObjectのインスタンスは、 Python bytearray 型を示します。 Python レイヤでのbytearrayと同じオブジェクトです。
型チェックマクロ¶
ダイレクト API 関数¶
-
PyObject *PyByteArray_FromObject(PyObject *o)¶
- 戻り値: 新しい参照。 次に属します: Stable ABI. Thread safety: Safe for concurrent use on the same object.
buffer protocol を実装した任意のオブジェクト o から、新しいbytearrayオブジェクトを作成し、返します。
On failure, return
NULLwith an exception set.注釈
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)¶
- 戻り値: 新しい参照。 次に属します: 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)¶
- 戻り値: 新しい参照。 次に属します: Stable ABI. Thread safety: Safe for concurrent use on the same object.
bytearray a と b を連結した結果を新しい bytearray として返します。
On failure, return
NULLwith an exception set.注釈
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)¶
- 次に属します: Stable ABI. Thread safety: Atomic.
NULLポインタチェックの後に bytearray のサイズを返します。
-
char *PyByteArray_AsString(PyObject *bytearray)¶
- 次に属します: Stable ABI. Thread safety: Safe to call from multiple threads with external synchronization only.
NULLポインタチェックの後に bytearray の内容を char 配列として返します。 返される配列には、常に余分な null バイトが追加されます。注釈
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)¶
- 次に属します: Stable ABI.
Resize the internal buffer of bytearray to len. Failure is a
-1return with an exception set.バージョン 3.14 で変更: A negative len will now result in an exception being set and -1 returned.
マクロ¶
以下のマクロは、ポインタのチェックをしないことにより安全性を犠牲にしてスピードを優先しています。
-
char *PyByteArray_AS_STRING(PyObject *bytearray)¶
- Thread safety: Safe to call from multiple threads with external synchronization only.
PyByteArray_AsString()に似ていますが、エラーチェックを行いません。注釈
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.
PyByteArray_Size()に似ていますが、エラーチェックを行いません。