⚡️ Speed up method VertexAITextEmbeddingConfig.get_config by 44%
#123
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.
📄 44% (0.44x) speedup for
VertexAITextEmbeddingConfig.get_configinlitellm/llms/vertex_ai/vertex_embeddings/transformation.py⏱️ Runtime :
2.97 milliseconds→2.07 milliseconds(best of30runs)📝 Explanation and details
Summary of optimizations:
__init__, replaced the loop andlocals().copy()with direct checks/assignments for the three arguments, reducing work and memory usage.get_config, replaced explicitisinstancechecks for function/method types with a singlecallablecheck, which covers all function, method, classmethod, and staticmethod types and is faster for filtering out functions/methods.✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
To edit these changes
git checkout codeflash/optimize-VertexAITextEmbeddingConfig.get_config-mhc5yf5rand push.