/src/cpython-install/include/python3.15/cpython/bytearrayobject.h
Line | Count | Source |
1 | | #ifndef Py_CPYTHON_BYTEARRAYOBJECT_H |
2 | | # error "this header file must not be included directly" |
3 | | #endif |
4 | | |
5 | | /* Object layout */ |
6 | | typedef struct { |
7 | | PyObject_VAR_HEAD |
8 | | /* How many bytes allocated in ob_bytes |
9 | | |
10 | | In the current implementation this is equivalent to Py_SIZE(ob_bytes_object). |
11 | | The value is always loaded and stored atomically for thread safety. |
12 | | There are API compatibilty concerns with removing so keeping for now. */ |
13 | | Py_ssize_t ob_alloc; |
14 | | char *ob_bytes; /* Physical backing buffer */ |
15 | | char *ob_start; /* Logical start inside ob_bytes */ |
16 | | Py_ssize_t ob_exports; /* How many buffer exports */ |
17 | | PyObject *ob_bytes_object; /* PyBytes for zero-copy bytes conversion */ |
18 | | } PyByteArrayObject; |
19 | | |
20 | | /* Macros and static inline functions, trading safety for speed */ |
21 | | #define _PyByteArray_CAST(op) \ |
22 | | (assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op)) |
23 | | |
24 | | static inline char* PyByteArray_AS_STRING(PyObject *op) |
25 | 0 | { |
26 | 0 | return _PyByteArray_CAST(op)->ob_start; |
27 | 0 | } |
28 | | #define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self)) |
29 | | |
30 | 0 | static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) { |
31 | 0 | PyByteArrayObject *self = _PyByteArray_CAST(op); |
32 | 0 | #ifdef Py_GIL_DISABLED |
33 | 0 | return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(self)->ob_size)); |
34 | 0 | #else |
35 | 0 | return Py_SIZE(self); |
36 | 0 | #endif |
37 | 0 | } |
38 | | #define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self)) |