How to improve insert image and merge document performance

# insert image using aspose word cloud
 insert_request = asposewordscloud.models.requests.InsertDrawingObjectOnlineRequest(
            document=document,
            drawing_object=request_drawing_object,
            image_file=image, node_path=node_path)
        result = self.aspose_api.insert_drawing_object_online(insert_request)


# merge documents
request_document_list_document_entries0 = asposewordscloud.DocumentEntry(
            file_reference=request_document_list_document_entries0_file_reference, 
            import_format_mode='KeepSourceFormatting')
request_document_list_document_entries = [request_document_list_document_entries0]
    request_document_list = asposewordscloud.DocumentEntryList(document_entries=request_document_list_document_entries)
    append_request = asposewordscloud.models.requests.AppendDocumentOnlineRequest(document=request_document, document_list=request_document_list)
    result = aspose.aspose_api.append_document_online(append_request)

Here are two cases mentioned in the code: inserting an image and merging two documents. Is this code appropriate for Python, given that we are currently using Aspose version “aspose-words-cloud==23.2.0”? Is this suitable for the above code, and how can we improve the speed of these two sections?

Thanks for your request.
I don’t understand what you mean by “Is this code appropriate for Python?”
The performance of these operations depends on many things, like document structure, size, image size, etc.
If you want to increase speed, you may use batch API, where you can specify multiple requests, then send them in one batch and get the final result.
An example of batch request can be found here aspose-words-cloud-python/test/test_batch.py at b669b591a39e23db2f7371b4824bf1a7ac968e79 · aspose-words-cloud/aspose-words-cloud-python · GitHub

def add_padding(self, document,table_row_path,space):
        request_format = asposewordscloud.TableCellFormat(bottom_padding=space, right_padding=space, top_padding=space, left_padding=space)
        update_request = asposewordscloud.models.requests.UpdateTableCellFormatOnlineRequest(document=document,
                                                                                             table_row_path=table_row_path,
                                                                                             format=request_format,
                                                                                             index=0)
        result = self.aspose_api.update_table_cell_format_online(update_request)

def insert_image(self, document, image, node_path, width, height):
        request_drawing_object = asposewordscloud.DrawingObjectInsert(height=height, left=0, top=0, width=width,
                                                                      relative_horizontal_position='Margin',
                                                                      relative_vertical_position='Margin',
                                                                      wrap_type='Inline')
        insert_request = asposewordscloud.models.requests.InsertDrawingObjectOnlineRequest(
            document=document,
            drawing_object=request_drawing_object,
            image_file=image, node_path=node_path)
        result = self.aspose_api.insert_drawing_object_online(insert_request)

Could you combine two functions into one and execute them together as a batch request?

Yes, it is possible to execute them in one batch request, you can give it a try using the example I shared above, but replace the requests on yours, if you face any issues, please let us know