On Sun, May 01, 2016 at 09:25:17PM -0400, Random832 wrote:
Is there any reason not to simply implement a performance optimization for the normal syntax?
Yes. You can't assume that myobject is the same object in both statements. A silly toy example:
class MyObject: def deactivate(self): global myobject myobject = None def fire(self): launch_missiles()
A more realistic case would be if you have a mutable object:
The compiler cannot assume that (myobject.lookup['key'].property) will refer to the same thing in the two calls. But the programmer can explicitly do so, using either a temporary variable, or the proposed "using" statement.