⚡️ Speed up method JiraDataSource.delete_workflow_scheme by 7%
#1019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📄 7% (0.07x) speedup for
JiraDataSource.delete_workflow_schemeinbackend/python/app/sources/external/jira/jira.py⏱️ Runtime :
3.04 milliseconds→2.85 milliseconds(best of51runs)📝 Explanation and details
The optimization achieves a 6% runtime improvement through a targeted micro-optimization in the
_as_str_dicthelper function. The key change adds an early return for empty dictionaries:Why this optimization works:
_queryand sometimes_headers), the optimization skips the expensive dictionary comprehension that calls_serialize_value()for each itemstr()and_serialize_value()calls when unnecessaryPerformance impact from line profiler data:
_as_str_dictfunction calls reduced from 2.71ms total time to 2.42ms (10% improvement in this helper)delete_workflow_schemeinvocation (for headers, path_params, query_params)_queryparameters in this Jira API endpointTest case optimization benefits:
The improvement is most significant for test cases with minimal or no headers/query parameters, which represents typical API usage patterns. Tests with large headers or concurrent requests still benefit proportionally from the reduced per-call overhead.
While throughput remains constant at ~31,161 operations/second, the 6% runtime reduction directly translates to lower latency per operation, making this optimization valuable for high-frequency API calls where every microsecond counts.
✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
To edit these changes
git checkout codeflash/optimize-JiraDataSource.delete_workflow_scheme-miq6gdlpand push.