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

ObjectId creation from BSON could be optimized

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      When decoding a BSON string the generation of ObjectIds could be optimized to avoid several function calls.

      For example, instead of creating ObjectIds the BSON decoder could create objects of this class:

          class _ObjectIdFromString(ObjectId):
              def __init__(self, oid):
                  self._ObjectId__id = oid
      

      This new class is just providing a simplification of ObjectId.__init__ for the case when the input is known to be a sequence of 12 bytes.

      The changes to the c extension would be trivial, the attached patch file shows the 4 lines that require changes.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            unbeknownst unbeknownst
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: