On Fri, Dec 18, 2020 at 01:23:34AM +1300, Greg Ewing wrote:
> On 17/12/20 11:25 pm, Paul Sokolovsky wrote:
> >CPython compiles "(a.b)()" using LOAD_METHOD not because it consciously 
> >"optimizes" it,
> >but simply because it's *unable* to represent the difference between
> >"a.b()" and "(a.b)()".
> 
> I'm pretty sure whoever added the optimisation fully intended it
> to apply to (a.b)() as well as a.b() -- given that they are
> supposed to have the same semantics, why would you *not* want
> to optimise both? So even if the AST were able to distinguish
> between them, there would be no reason to do so.


Not only are they *supposed* to have the same semantics, but they 
*literally do* have the same semantics.

The CALL_METHOD op code doesn't just call methods, just as the 
CALL_FUNCTION op code doesn't just call functions. The only difference 
between them is the implementation of *how* they perform the call.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7PSRW4WNIPBIZN6U2XR5X576EB7N3I43/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to