-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Internal
-
None
The message module __pack_message function requires us to copy the encoded command document twice. First to generate the "data" and second to generate the full wire protocol message.
To reduce the number of data copies, we could add _pack_message_parts(operation, msg_parts) that accepts a list of message parts. It could perform a single b"".join() instead of the two levels of copies that are required by _pack_message
Another option would be to never join the byte strings in the first place. We could
instead, pass a list of byte strings to send over the network:
msg_parts = [msg_header, msg_part2, msg_part3, ...] for part in msg_parts: sock.send(part)