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

_cbson_dict_to_bson should not copy RawBSONDocument.raw object

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6
    • Component/s: BSON
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: