|
|
Subscribe / Log in / New account

Lazy imports for Python

Lazy imports for Python

Posted Sep 9, 2022 19:05 UTC (Fri) by smurf (subscriber, #17840)
In reply to: Lazy imports for Python by azumanga
Parent article: Lazy imports for Python

This is why you have tests.

The same kind of argument has been used 20 years ago when libc started to use lazy loading. The solution was a loader flag that loaded eagerly and reported when something didn't resolve. On Python, the equivalent solution might well be a dedicated import checker.

Fortunately, tools like that do exist already. :-P


to post comments

Lazy imports for Python

Posted Sep 11, 2022 19:24 UTC (Sun) by NYKevin (subscriber, #129325) [Link]

Also, if you're trying to *catch* the exception, then it will automatically be eager because it's not a top-level import anymore (at an absolute minimum, it's inside of a try block).


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds