Avoid multiple levels of byte join()s in message/bson module

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Gone away
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Internal
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • 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)
      

            Assignee:
            Unassigned
            Reporter:
            Shane Harvey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: