Home / Function/ __getattr__() — langchain Function Reference

__getattr__() — langchain Function Reference

Architecture documentation for the __getattr__() function in __init__.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fcc6f0df_f027_4fb1_9783_0e4e19ec9208["__getattr__()"]
  18652305_99f1_0cae_e1b2_fa3d6c387ab1["__init__.py"]
  fcc6f0df_f027_4fb1_9783_0e4e19ec9208 -->|defined in| 18652305_99f1_0cae_e1b2_fa3d6c387ab1
  style fcc6f0df_f027_4fb1_9783_0e4e19ec9208 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/vectorstores/__init__.py lines 26–44

def __getattr__(attr_name: str) -> object:
    """Dynamically import and return an attribute from a submodule.

    This function enables lazy loading of vectorstore classes from submodules, reducing
    initial import time and circular dependency issues.

    Args:
        attr_name: Name of the attribute to import.

    Returns:
        The imported attribute object.

    Raises:
        AttributeError: If the attribute is not found in `_dynamic_imports`.
    """
    module_name = _dynamic_imports.get(attr_name)
    result = import_attr(attr_name, module_name, __spec__.parent)
    globals()[attr_name] = result
    return result

Subdomains

Frequently Asked Questions

What does __getattr__() do?
__getattr__() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/__init__.py.
Where is __getattr__() defined?
__getattr__() is defined in libs/core/langchain_core/vectorstores/__init__.py at line 26.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free