Skip to content

Commit 13fcb04

Browse files
authored
Merge pull request #1826 from codeflash-ai/codeflash/optimize-pr1199-2026-03-13T01.03.06
⚡️ Speed up method `TestGenRequest.to_payload` by 20% in PR #1199 (`omni-java`)
2 parents e1081d4 + ee6749f commit 13fcb04

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

codeflash/api/schemas.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from enum import Enum
1818
from typing import Any
1919

20+
_PLATFORM_PYTHON_VERSION = platform.python_version()
21+
2022

2123
class ModuleSystem(str, Enum):
2224
"""Module system used by the code."""
@@ -189,6 +191,9 @@ class TestGenRequest:
189191

190192
def to_payload(self) -> dict[str, Any]:
191193
"""Convert to API payload dict, maintaining backward compatibility."""
194+
# Backward compat: backend still expects python_version
195+
python_version = self.language_info.version if self.language_info.name == "python" else _PLATFORM_PYTHON_VERSION
196+
192197
payload = {
193198
"source_code_being_tested": self.source_code,
194199
"function_to_optimize": {"function_name": self.function_name, "is_async": self.is_async},
@@ -203,18 +208,10 @@ def to_payload(self) -> dict[str, Any]:
203208
"codeflash_version": self.codeflash_version,
204209
"is_async": self.is_async,
205210
"is_numerical_code": self.is_numerical_code,
211+
"language_version": self.language_info.version,
212+
"python_version": python_version,
206213
}
207214

208-
# Add language version (canonical for all languages)
209-
payload["language_version"] = self.language_info.version
210-
211-
# Backward compat: backend still expects python_version
212-
import platform
213-
214-
payload["python_version"] = (
215-
self.language_info.version if self.language_info.name == "python" else platform.python_version()
216-
)
217-
218215
# Module system for JS/TS
219216
if self.language_info.module_system != ModuleSystem.UNKNOWN:
220217
payload["module_system"] = self.language_info.module_system.value

0 commit comments

Comments
 (0)