bytearray.pxd 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. from .object cimport PyObject
  2. cdef extern from "Python.h":
  3. bint PyByteArray_Check(object o)
  4. # Return true if the object o is a bytearray object or an instance of a subtype of the bytearray type.
  5. bint PyByteArray_CheckExact(object o)
  6. # Return true if the object o is a bytearray object, but not an instance of a subtype of the bytearray type.
  7. bytearray PyByteArray_FromObject(object o)
  8. # Return a new bytearray object from any object, o, that implements the buffer protocol.
  9. bytearray PyByteArray_FromStringAndSize(char *string, Py_ssize_t len)
  10. # Create a new bytearray object from string and its length, len. On failure, NULL is returned.
  11. bytearray PyByteArray_Concat(object a, object b)
  12. # Concat bytearrays a and b and return a new bytearray with the result.
  13. Py_ssize_t PyByteArray_Size(object bytearray)
  14. # Return the size of bytearray after checking for a NULL pointer.
  15. char* PyByteArray_AsString(object bytearray)
  16. # Return the contents of bytearray as a char array after checking for a NULL pointer.
  17. # The returned array always has an extra null byte appended.
  18. int PyByteArray_Resize(object bytearray, Py_ssize_t len)
  19. # Resize the internal buffer of bytearray to len.
  20. char* PyByteArray_AS_STRING(object bytearray)
  21. # Macro version of PyByteArray_AsString().
  22. Py_ssize_t PyByteArray_GET_SIZE(object bytearray)
  23. # Macro version of PyByteArray_Size().