[Python-ideas] Object grabbing

Random832 random832 at fastmail.com
Sun May 1 21:41:10 EDT 2016


On Sun, May 1, 2016, at 21:36, Steven D'Aprano wrote:
> 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:
[snip]
> A more realistic case would be if you have a mutable object:
[snip]

Well, by "normal" I meant assigning it to a temporary variable... and a
local one, at that. Too bad there's no easy way to get a quick local
scope without making a function, for stuff at the module level...


More information about the Python-ideas mailing list