ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • None
    • Python Drivers
    • 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

      Summary:
      Fix is_dict_class detection to use the fast decode path. This is performance gap, not a correctness bug.

      Description:

      Context

      is_dict_class is computed with Py_IS_TYPE(options->document_class, &PyDict_Type). document_class is a class (a type object), and Py_IS_TYPE(x, T) is Py_TYPE == T. So we are comparing{{Py_TYPE(&PyDict_Type) == &PyDict_Type}}, which is false (it is PyType_Type). So is_dict_class was always false, forcing every document decode through the generic PyObject_SetItem path instead of the fast PyDict_SetItem path, adding object churn.

      Definition of done

      • Compute is_dict_class with an identity comparison: options->document_class == (PyObject*)&PyDict_Type.
      • test_bson.py and test_bson_corpus.py pass.

      Pitfalls

      • document_class is a class, not an instance, so Py_IS_TYPE is the wrong check; use identity equality.

            Assignee:
            Unassigned
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: