⚡️ Speed up method AsyncOperationPool._get_operation by 10% (#1914)
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -83,7 +83,11 @@ class AsyncOperationPool:
|
|||||||
self._add_operation(task_id, operation)
|
self._add_operation(task_id, operation)
|
||||||
|
|
||||||
def _get_operation(self, task_id: str, agent_phase: AgentPhase) -> AsyncOperation | None:
|
def _get_operation(self, task_id: str, agent_phase: AgentPhase) -> AsyncOperation | None:
|
||||||
return self._operations.get(task_id, {}).get(agent_phase, None)
|
# Direct dictionary access and exception handling to minimize overhead
|
||||||
|
try:
|
||||||
|
return self._operations[task_id][agent_phase]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
def _remove_operations(self, task_id: str) -> None:
|
def _remove_operations(self, task_id: str) -> None:
|
||||||
if task_id in self._operations:
|
if task_id in self._operations:
|
||||||
|
|||||||
Reference in New Issue
Block a user