From ed4952e475f8d0c4cb4c388106a14d61e97ee20b Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Fri, 15 Nov 2024 10:53:53 -0500 Subject: [PATCH] core[patch]: add caching to get_function_nonlocals (#28131) --- libs/core/langchain_core/runnables/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/core/langchain_core/runnables/utils.py b/libs/core/langchain_core/runnables/utils.py index 06168a176d0..a81ca7615a6 100644 --- a/libs/core/langchain_core/runnables/utils.py +++ b/libs/core/langchain_core/runnables/utils.py @@ -388,6 +388,7 @@ def get_lambda_source(func: Callable) -> Optional[str]: return name +@lru_cache(maxsize=256) def get_function_nonlocals(func: Callable) -> list[Any]: """Get the nonlocal variables accessed by a function.