[Python-ideas] Delayed Execution via Keyword

tritium-list at sdamon.com tritium-list at sdamon.com
Mon Feb 20 06:18:19 EST 2017



> -----Original Message-----
> From: Python-ideas [mailto:python-ideas-bounces+tritium-
> list=sdamon.com at python.org] On Behalf Of Michel Desmoulin
> Sent: Monday, February 20, 2017 3:30 AM
> To: python-ideas at python.org
> Subject: Re: [Python-ideas] Delayed Execution via Keyword
> 
> I wrote a blog post about this, and someone asked me if it meant
> allowing lazy imports to make optional imports easier.
> 
> Someting like:
> 
> lazy import foo
> lazy from foo import bar
> 
> So now if I don't use the imports, the module is not loaded, which could
> also significantly speed up applications starting time with a lot of
> imports.

Would that not also make a failure to import an error at the time of
executing the imported piece of code rather than at the place of import?
And how would optional imports work if they are not loaded until use?  Right
now, optional imports are done by wrapping the import statement in a
try/except, would you not need to do that handling everywhere the imported
object is used instead?

(I haven't been following the entire thread, and I don't know if this is a
forest/tress argument)

> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



More information about the Python-ideas mailing list