def read(self, size=None):
        """Read at most size bytes from this buffer.

        Bytes read from this buffer are consumed and are permanently removed.

        Args:
          size: If provided, read no more than size bytes from the buffer.
            Otherwise, this reads the entire buffer.

        Returns:
          The bytes read from this buffer.
        """
        if size is None:
            size = self.__size
        ret_list = []
        while size > 0 and self.__buf:
            data = self.__buf.popleft()
            size -= len(data)
            ret_list.append(data)
        if size < 0:
            ret_list[-1], remainder = ret_list[-1][:size], ret_list[-1][size:]
            self.__buf.appendleft(remainder)
        ret = b''.join(ret_list)
        self.__size -= len(ret)
        return ret
def read ( self , size = None ) : if size is None : size = self . __size ret_list = [ ] while size > 0 and self . __buf : data = self . __buf . popleft ( ) size -= len ( data ) ret_list . append ( data ) if size < 0 : ret_list [ - 1 ] , remainder = ret_list [ - 1 ] [ : size ] , ret_list [ - 1 ] [ size : ] self . __buf . appendleft ( remainder ) ret = b'' . join ( ret_list ) self . __size -= len ( ret ) return ret
Read at most size bytes from this buffer.

        Bytes read from this buffer are consumed and are permanently removed.

        Args:
          size: If provided, read no more than size bytes from the buffer.
            Otherwise, this reads the entire buffer.

        Returns:
          The bytes read from this buffer.