Skip to content

Conversation

@codeflash-ai
Copy link

@codeflash-ai codeflash-ai bot commented Oct 29, 2025

📄 44% (0.44x) speedup for VertexAITextEmbeddingConfig.get_config in litellm/llms/vertex_ai/vertex_embeddings/transformation.py

⏱️ Runtime : 2.97 milliseconds 2.07 milliseconds (best of 30 runs)

📝 Explanation and details

Summary of optimizations:

  • In __init__, replaced the loop and locals().copy() with direct checks/assignments for the three arguments, reducing work and memory usage.
  • In get_config, replaced explicit isinstance checks for function/method types with a single callable check, which covers all function, method, classmethod, and staticmethod types and is faster for filtering out functions/methods.
  • No changes to type annotations, names, or logic.
  • No change in side-effects, return values, or raised exceptions.

Correctness verification report:

Test Status
⚙️ Existing Unit Tests 🔘 None Found
🌀 Generated Regression Tests 11 Passed
⏪ Replay Tests 🔘 None Found
🔎 Concolic Coverage Tests 🔘 None Found
📊 Tests Coverage 100.0%
🌀 Generated Regression Tests and Runtime
import types
from typing import Literal, Optional

# imports
import pytest
from litellm.llms.vertex_ai.vertex_embeddings.transformation import \
    VertexAITextEmbeddingConfig
from pydantic import BaseModel

# unit tests

# -------- Basic Test Cases --------















#------------------------------------------------
import types
from typing import Literal, Optional

# imports
import pytest  # used for our unit tests
from litellm.llms.vertex_ai.vertex_embeddings.transformation import \
    VertexAITextEmbeddingConfig
from pydantic import BaseModel

# unit tests

# ---- Basic Test Cases ----























#------------------------------------------------
from litellm.llms.vertex_ai.vertex_embeddings.transformation import VertexAITextEmbeddingConfig

To edit these changes git checkout codeflash/optimize-VertexAITextEmbeddingConfig.get_config-mhc5yf5r and push.

Codeflash

**Summary of optimizations:**
- In `__init__`, replaced the loop and `locals().copy()` with direct checks/assignments for the three arguments, reducing work and memory usage.
- In `get_config`, replaced explicit `isinstance` checks for function/method types with a single `callable` check, which covers all function, method, classmethod, and staticmethod types and is faster for filtering out functions/methods.
- No changes to type annotations, names, or logic.
- No change in side-effects, return values, or raised exceptions.
@codeflash-ai codeflash-ai bot requested a review from mashraf-222 October 29, 2025 15:41
@codeflash-ai codeflash-ai bot added ⚡️ codeflash Optimization PR opened by Codeflash AI 🎯 Quality: High Optimization Quality according to Codeflash labels Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚡️ codeflash Optimization PR opened by Codeflash AI 🎯 Quality: High Optimization Quality according to Codeflash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant