This PR optimized the handling of IonPyDict objects. In the previous implementation, we converted the PyObject map into a sequence for iteration. The updated approach introduced in this PR separates the handling into two cases based on the type of the map object:
For Python dictionaries: When map is a standard Python dictionary, we iterate over it directly using PyDict_Next.
For IonPyDict objects: In cases where map is an instance of IonPyDict, we now access its _ _store attribute. This attribute itself is a Python dictionary. By doing so, we can then use PyDict_Next to iterate over __store, similar to how we handle standard Python dictionaries.
This optimization eliminates the need to convert IonPyDict objects into sequences before iteration, leading to a more efficient processing process.
Here are the benchmark results from benchmarking ion-python writing using service_log_legacy:
There is 31.2% performance improvement from the change.
To reproduce this results, please run:
python ion_benchmark_cli.py write --iterations 30 --warmups 10 --io-type fileservice_log_legacy.ion --format ion_binary
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue #, if available:
Description of changes:
This PR optimized the handling of
IonPyDict
objects. In the previous implementation, we converted thePyObject
map into asequence
for iteration. The updated approach introduced in this PR separates the handling into two cases based on the type of the map object:map
is a standard Python dictionary, we iterate over it directly usingPyDict_Next
.IonPyDict
objects: In cases where map is an instance of IonPyDict, we now access its_ _store
attribute. This attribute itself is a Python dictionary. By doing so, we can then usePyDict_Next
to iterate over __store, similar to how we handle standard Python dictionaries.This optimization eliminates the need to convert IonPyDict objects into sequences before iteration, leading to a more efficient processing process.
Here are the benchmark results from benchmarking ion-python writing using service_log_legacy: There is 31.2% performance improvement from the change.
To reproduce this results, please run:
python ion_benchmark_cli.py write --iterations 30 --warmups 10 --io-type fileservice_log_legacy.ion --format ion_binary