⚡️ Speed up function get_current_org_with_authentication by 24%
#149
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.
📄 24% (0.24x) speedup for
get_current_org_with_authenticationinskyvern/forge/sdk/services/org_auth_service.py⏱️ Runtime :
463 microseconds→375 microseconds(best of57runs)📝 Explanation and details
The optimization eliminates an unnecessary function call by inlining the
_authenticate_helperfunction directly intoget_current_org_with_authentication. This simple refactoring removes the overhead of an async function call while preserving identical functionality.Key changes:
authorization.split(" ")[1]) and authentication logic directly into the main function_authenticate_helperfunction entirelyWhy this improves performance:
await _authenticate_helper(authorization), which includes function setup, parameter passing, and coroutine creationPerformance impact:
Test case benefits:
The optimization performs well across all scenarios:
This is a classic case where function inlining provides measurable performance gains without any behavioral changes - particularly valuable in authentication code that's likely called frequently in request processing pipelines.
✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
To edit these changes
git checkout codeflash/optimize-get_current_org_with_authentication-mjamfakqand push.