def append(self, data: Union[bytes, bytearray, memoryview]) -> None:
        """
        Append the given piece of data (should be a buffer-compatible object).
        """
        size = len(data)
        if size > self._large_buf_threshold:
            if not isinstance(data, memoryview):
                data = memoryview(data)
            self._buffers.append((True, data))
        elif size > 0:
            if self._buffers:
                is_memview, b = self._buffers[-1]
                new_buf = is_memview or len(b) >= self._large_buf_threshold
            else:
                new_buf = True
            if new_buf:
                self._buffers.append((False, bytearray(data)))
            else:
                b += data  # type: ignore

        self._size += size
def append ( self , data : Union [ bytes , bytearray , memoryview ] ) -> None : size = len ( data ) if size > self . _large_buf_threshold : if not isinstance ( data , memoryview ) : data = memoryview ( data ) self . _buffers . append ( ( True , data ) ) elif size > 0 : if self . _buffers : is_memview , b = self . _buffers [ - 1 ] new_buf = is_memview or len ( b ) >= self . _large_buf_threshold else : new_buf = True if new_buf : self . _buffers . append ( ( False , bytearray ( data ) ) ) else : b += data self . _size += size
Append the given piece of data (should be a buffer-compatible object).