langchain-ai
langchain
BlogDocsChangelog

perf(core): move origin type map to module level in function_calling.py

#34481
Comparing
Rudra-Tiwari-codes:perf/module-level-origin-map
(
2c25dc8
) with
master
(
75b07b3
)
CodSpeed Performance Gauge
+6%
Untouched
13
Skipped
21

Benchmarks

Skipped (21)

Passed

test_import_time[RunnableLambda]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+10%
540.6 ms491.6 ms
test_import_time[PydanticOutputParser]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+9%
582.7 ms534 ms
test_import_time[LangChainTracer]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+9%
480 ms442.2 ms
test_import_time[Runnable]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+8%
533.9 ms493.8 ms
test_import_time[BaseChatModel]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+8%
574.2 ms531.4 ms
test_import_time[ChatPromptTemplate]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+7%
646.1 ms602.5 ms
test_import_time[InMemoryVectorStore]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+7%
660.5 ms616.1 ms
test_import_time[tool]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+7%
555.8 ms519.2 ms
test_import_time[InMemoryRateLimiter]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+7%
186 ms174.2 ms
test_import_time[Document]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+4%
196.2 ms187.8 ms
test_import_time[CallbackManager]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+4%
482 ms462.4 ms
test_import_time[HumanMessage]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
273.9 ms267.6 ms
test_async_callbacks_in_sync
libs/core/tests/benchmarks/test_async_callbacks.py
CodSpeed Performance Gauge
0%
24.4 ms24.4 ms

Commits

Click on a commit to change the comparison range
Base
master
75b07b3
+6.37%
perf(core): move origin type map to module level in function_calling.py Move _ORIGIN_MAP dict from inside _py_38_safe_origin() to module level constant. This avoids dict allocation on every function call, reducing garbage collection pressure during frequent tool conversions. The function is called during typed dict to pydantic model conversion which happens during tool binding and invocation.
2c25dc8
18 hours ago
by Rudra-Tiwari-codes
© 2025 CodSpeed Technology
Home Terms Privacy Docs