[Python-ideas] Delayed Execution via Keyword
Abe Dillon
abedillon at gmail.com
Mon Feb 20 19:52:49 EST 2017
On Fri, Feb 17, 2017, Steven D'Aprano wrote:
> JIT compilation delays *compiling* the code to run-time. This is a
> proposal for delaying *running* the code until such time as some other
> piece of code actually needs the result.
My thought was that if a compiler is capable of determining what needs to
be compiled just in time, then an interpreter might be able to determine
what expressions need to be evaluated just when their results are actually
used.
So if you had code that looked like:
>>> log.debug("data: %s", expensive())
The interpreter could skip evaluating the expensive function if the result
is never used. It would only evaluate it "just in time". This would almost
certainly require just in time compilation as well, otherwise the byte code
that calls the "log.debug" function would be unaware of the byte code that
implements the function.
This is probably a pipe-dream, though; because the interpreter would have
to be aware of side effects.
On Mon, Feb 20, 2017 at 5:18 AM, <tritium-list at sdamon.com> wrote:
>
>
> > -----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/
>
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170220/36d0e745/attachment.html>
More information about the Python-ideas
mailing list