Created
July 1, 2026 02:08
-
-
Save siscia/5549989a8a6cc8529521311471c06aee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("executing foo/__init__.py") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("executing foo/bar.py") | |
| class RandomClass: | |
| print("executing RandomClass body") | |
| def __init__(self) -> None: | |
| print("executing RandomClass.__init__") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("before lazy import") | |
| lazy from foo.bar import RandomClass | |
| print("after lazy import") | |
| print("before first use") | |
| instance = RandomClass() | |
| print("after first use") | |
| print(f"instance type: {type(instance).__name__}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| simone@simones-Apple-MacBook-Pro tmp.zEmX5KWOEG % uv run python lazy_import_demo.py | |
| before lazy import | |
| after lazy import | |
| before first use | |
| executing foo/__init__.py | |
| executing foo/bar.py | |
| executing RandomClass body | |
| executing RandomClass.__init__ | |
| after first use | |
| instance type: RandomClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment