On Sun, Jul 2, 2017 at 3:41 PM, Steven D'Aprano <st...@pearwood.info> wrote:
>> Let's say that you do. Given how short it is, it would just get inlined.
>> Your call of mysum ("a", "b") would indeed not use IADD, nor would it be
>> a call. It would potentially not invoke any operators, but instead get
>> replaced with "ab".
>
> What you are describing sounds more like the output of a keyhole
> optimizer that folds constants, only extended to look inside functions.
> I expect that it would have to be a VERY clever optimizer, since it
> would have to do a complete whole-of-program static analysis to be sure
> that mysum has not been replaced, shadowed or redefined by the time it
> is called.
>
> I won't say that is outright impossible, but it would be *extremely*
> hard to do something like that at compile time.

Isn't that the sort of thing that the "versioned globals dictionary"
was supposed to do? If your globals haven't changed, you know that the
optimizer was correct.

But that's still a hard problem. Or at very least, it's decidedly
non-trivial, and the costs are significant, so the net benefits aren't
proven.

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

Reply via email to