mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	[extractor] Import _ALL_CLASSES lazily
				
					
				
			This significantly speeds up `import yt_dlp` in the absence of `lazy_extractors`
This commit is contained in:
		| @@ -33,7 +33,7 @@ def _is_package(module): | ||||
| 
 | ||||
| def passthrough_module(parent, child, *, callback=lambda _: None): | ||||
|     parent_module = importlib.import_module(parent) | ||||
|     child_module = importlib.import_module(child, parent) | ||||
|     child_module = None  # Import child module only as needed | ||||
| 
 | ||||
|     class PassthroughModule(types.ModuleType): | ||||
|         def __getattr__(self, attr): | ||||
| @@ -41,6 +41,9 @@ def passthrough_module(parent, child, *, callback=lambda _: None): | ||||
|                 with contextlib.suppress(ImportError): | ||||
|                     return importlib.import_module(f'.{attr}', parent) | ||||
| 
 | ||||
|             nonlocal child_module | ||||
|             child_module = child_module or importlib.import_module(child, parent) | ||||
| 
 | ||||
|             ret = _NO_ATTRIBUTE | ||||
|             with contextlib.suppress(AttributeError): | ||||
|                 ret = getattr(child_module, attr) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan