Skip to main content

cached_import

Imports a specified class from a module, utilizing the system cache to retrieve the module if it is already fully initialized or performing a fresh import if necessary.

def cached_import(
module_path: string,
class_name: string
) - > Any

Dynamically imports a module and retrieves a specific attribute from it, utilizing the system cache to avoid redundant initialization.

Parameters

NameTypeDescription
module_pathstringThe full dot-notation path of the Python module to import.
class_namestringThe name of the class or attribute to retrieve from the imported module.

Returns

TypeDescription
AnyThe class or attribute retrieved from the specified module.