Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Cache RunnableLambda deps #29200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Jan 14, 2025

RunnableLambda's deps may do costly OS operation by calling get_function_nonlocals.
So it's better to cache it.
See #29043

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2025 10:26am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Jan 14, 2025
Copy link
Member

@efriis efriis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just do a @functools.cached_property?

@efriis efriis self-assigned this Jan 15, 2025
@cbornet cbornet force-pushed the cache-runnablelambda-deps branch from 3194c99 to e1e22d6 Compare January 16, 2025 10:26
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 16, 2025
@cbornet
Copy link
Collaborator Author

cbornet commented Jan 16, 2025

why not just do a @functools.cached_property?

Of course, much better!
Done.

@cbornet cbornet requested a review from efriis January 16, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants