[PR #6646] perf: remove importlib.metadata for faster version access #5191

Closed
opened 2026-02-20 17:51:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6646

State: closed
Merged: No


Summary

Removes usage of importlib.metadata.version() which adds ~5ms to import time. Instead, uses hardcoded version strings.

  • libs/langgraph/langgraph/version.py: Hardcode version directly
  • libs/cli/langgraph_cli/version.py: Re-export from __init__.py
  • libs/checkpoint-postgres/.../base.py: Import from langgraph.version instead of importlib.metadata

Benchmark Results

Metric Before After
Import time ~5ms ~0.1ms
Improvement - 50x faster

Test Plan

  • make lint passes on all modified packages (langgraph, cli, checkpoint-postgres)
  • Version imports work correctly
  • Benchmark confirms performance improvement

Closes #5040

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6646 **State:** closed **Merged:** No --- ## Summary Removes usage of `importlib.metadata.version()` which adds ~5ms to import time. Instead, uses hardcoded version strings. - **libs/langgraph/langgraph/version.py**: Hardcode version directly - **libs/cli/langgraph_cli/version.py**: Re-export from `__init__.py` - **libs/checkpoint-postgres/.../base.py**: Import from `langgraph.version` instead of `importlib.metadata` ## Benchmark Results | Metric | Before | After | |--------|--------|-------| | Import time | ~5ms | ~0.1ms | | Improvement | - | **50x faster** | ## Test Plan - [x] `make lint` passes on all modified packages (langgraph, cli, checkpoint-postgres) - [x] Version imports work correctly - [x] Benchmark confirms performance improvement Closes #5040
yindo added the pull-request label 2026-02-20 17:51:21 -05:00
yindo closed this issue 2026-02-20 17:51:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#5191