From 618e550f062ea04aff7803cf3e0087c1f811b78d Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Thu, 23 Jan 2025 19:09:07 +0100 Subject: [PATCH] core: Cache RunnableLambda deps (#29200) `RunnableLambda`'s `deps` may do costly OS operation by calling `get_function_nonlocals`. So it's better to cache it. See #29043 --- libs/core/langchain_core/runnables/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/langchain_core/runnables/base.py b/libs/core/langchain_core/runnables/base.py index 4ad7c04a739c8..9942174103c3e 100644 --- a/libs/core/langchain_core/runnables/base.py +++ b/libs/core/langchain_core/runnables/base.py @@ -4457,7 +4457,7 @@ def get_output_schema( module_name=module, ) - @property + @functools.cached_property def deps(self) -> list[Runnable]: """The dependencies of this Runnable.