The current implementation of the BSON C extension and the python code requires that all documents and specs be dict types or inherit from dict.
In order to be more "Pythonic", they should allow any object which implements the mapping protocol (dict-like objects) to be used.
In order to do this, the C extension would need to use PyMapping_Check instead of PyDict_Check, and PyObject_GetItem instead of PyDict_GetItem. The python code would need to use operator.isMappingType instead of isinstance(doc_or_spec, dict) for Python <2.6 and isinstance(doc_or_spec, collections.Mapping) for Python >=2.6.
- depends on
-
PYTHON-378 Inconsistency between pure Python BSON._dict_to_bson and _cbson._dict_to_bson
- Closed