Merge pull request #5914 from thought-machine/fix_slow_string_read

Make grpc-python ByteBuffer.bytes() linear
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
index 851389a..6ecdcf7 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
@@ -254,7 +254,7 @@
     if self.c_byte_buffer != NULL:
       with nogil:
         grpc_byte_buffer_reader_init(&reader, self.c_byte_buffer)
-      result = b""
+      result = bytearray()
       with nogil:
         while grpc_byte_buffer_reader_next(&reader, &data_slice):
           data_slice_pointer = gpr_slice_start_ptr(data_slice)
@@ -263,7 +263,7 @@
             result += (<char *>data_slice_pointer)[:data_slice_length]
       with nogil:
         grpc_byte_buffer_reader_destroy(&reader)
-      return result
+      return bytes(result)
     else:
       return None