-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: JSON, Performance
ilukyanchikov has created PR #1493: PYTHON-1374: Optimized performance by removing object_pairs_hook call if we need the default conversion to dict behavior in mongo-python-driver
Issue Text:
Optimized performance by removing object_pairs_hook call if we need the default conversion to dict behavior [jira task](https://jira.mongodb.org/projects/PYTHON/issues/PYTHON-1374)
In object_hook, a dictionary is already passed, and calling object_pairs_hook for casting pairs to dict is redundant.
I validated my changes with test_json_util cases. `pytest -v -s test/test_json_util.py`
Compare performance with TestJson*Decoding cases(changes affect performance only in these cases) `pytest -v -s test/performance/perf_test.py::TestJsonFlatDecoding test/performance/perf_test.py::TestJsonDeepDecoding test/performance/perf_test.py::TestJsonFullDecoding`
Test Name | master | current branch |
------------------ | ------------------ | -------------------- |
JsonFlatDecoding | 96.18636555725531 | 117.50816018425552 |
JsonDeepDecoding | 58.337081713027956 | 77.52136671585596 |
JsonFullDecoding | 33.81260536995342 | 38.88821810950474 |
This fix only works with JSONOptions where document_class is dict, and I haven't found cases where something other than dict was used.
- related to
-
PYTHON-1374 Optimize json_util performance
- Closed