Profiling revealed that a significant portion of time was being taken
by adding items to the IonPyDict. This change optimizes the
construction of IonPyDicts by building the dicts in the ioncmodule.
The impact appears to be an improvement of about 20-25% for parsing
the "service_log" benchmark files.
In implementing the PyDict code in the ioncmodule I learned that
since 3.7 the standard dict type is ordered. The equality of the
standard dict aligns with Ion equality and is preferable. I also
learned that PyDict_SetDefault (in the C API) and dict.setdefault()
(in Python) are a more efficient way to implement get|set logic.
I updated the IonPyDict python class to reflect the above.
The definition of an internal _factory class method optimizes
object construction and that pattern should be applied to the other
classes as well.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Profiling revealed that a significant portion of time was being taken by adding items to the IonPyDict. This change optimizes the construction of IonPyDicts by building the dicts in the ioncmodule.
The impact appears to be an improvement of about 20-25% for parsing the "service_log" benchmark files.
In implementing the PyDict code in the ioncmodule I learned that since 3.7 the standard dict type is ordered. The equality of the standard dict aligns with Ion equality and is preferable. I also learned that PyDict_SetDefault (in the C API) and dict.setdefault() (in Python) are a more efficient way to implement get|set logic.
I updated the IonPyDict python class to reflect the above.
The definition of an internal _factory class method optimizes object construction and that pattern should be applied to the other classes as well.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.