Debian Codegraph @

Include/cpython/bytesobject.h

raw
1 #ifndef Py_CPYTHON_BYTESOBJECT_H
2 # error "this header file must not be included directly"
3 #endif
4
5 typedef struct {
6 PyObject_VAR_HEAD
7 Py_DEPRECATED(3.11) Py_hash_t ob_shash;
8 char ob_sval[1];
9
10 /* Invariants:
11 * ob_sval contains space for 'ob_size+1' elements.
12 * ob_sval[ob_size] == 0.
13 * ob_shash is the hash of the byte string or -1 if not computed yet.
14 */
15 } PyBytesObject;
16
17 PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
18
19 /* Macros and static inline functions, trading safety for speed */
20 #define _PyBytes_CAST(op) \
21 (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
22
23 static inline char* PyBytes_AS_STRING(PyObject *op)
24 {
25 return _PyBytes_CAST(op)->ob_sval;
26 }
27 #define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op))
28
29 static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
30 PyBytesObject *self = _PyBytes_CAST(op);
31 return Py_SIZE(self);
32 }
33 #define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
34
35 PyAPI_FUNC(PyObject*) PyBytes_Join(PyObject *sep, PyObject *iterable);
36
37 // Deprecated alias kept for backward compatibility
38 Py_DEPRECATED(3.14) static inline PyObject*
39 _PyBytes_Join(PyObject *sep, PyObject *iterable)
40 {
41 return PyBytes_Join(sep, iterable);
42 }