Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1404

_cbson_dict_to_bson should not copy RawBSONDocument.raw object

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6
    • Affects Version/s: None
    • Component/s: BSON
    • None

      In pure Python, _dict_to_bson simply returns the RawBSONDocument.raw attribute:

      def _dict_to_bson(doc, check_keys, opts, top_level=True):
          """Encode a document to BSON."""
          if _raw_document_class(doc):
              return doc.raw
          ...
      

      In the C version _cbson_dict_to_bson, we copy the raw attribute to an intermediate buffer and then encode that buffer to a bytes instance. Let's just return the raw attribute the same way the python code does instead.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: