️ 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:
Saurabh Misra
2025-03-16 16:04:30 -07:00
committed by GitHub
parent f9832b1657
commit bc9afaeb3c

View File

@@ -83,7 +83,11 @@ class AsyncOperationPool:
self._add_operation(task_id, operation)
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:
if task_id in self._operations: