on-internet
← Community

Adding an extra line changes the lazy import object entirely

Stack Overflow ·

I ran this on Python 3.15: >>> lazy import json >>> type(globals()['json']) <class 'lazy_import'> I also ran this: >>> lazy import json >>> _ = globals()['json'] >>> type(_) <class 'module'> Why did the output mysteriously change? What caused the lazy import to reify? How can I properly store a reference to the lazy_import object without it reifying?

Comments

Sign in or sign up to comment and upvote.

No comments yet.