-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON, Performance Benchmarking
-
None
-
None
-
Python Drivers
-
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.
- blocks
-
PYTHON-6109 Stable-ABI (abi3) wheels for Python 3.11+
-
- Needs Triage
-
- is blocked by
-
PYTHON-6096 Add BSON benchmarking regression test support
-
- Needs Triage
-