Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
Thanks for the patch. I had looked at this long ago when I first added the ROT2 optimization and the ROT3/ROT2 optimization. It wasn't included because it wasn't worth the added complexity in the peepholer logic and because there were concerns about executing internally in a different order than specified by the code. Since LOAD_NAME and LOAD_GLOBAL are subject to user control, changing their order of evaluation causes a visible change in semantics. For example, the following result is different than before the patch. >>> class Dict(dict): ... def __getitem__(self, key): ... print(key) ... return dict.__getitem__(self, key) ... >>> ns = Dict() >>> exec('c=1; d=2; a,b=c,d', globals(), ns) d c For the most part, I'm not too excited about the patch because * it is limited to very simple cases that already have some optimization * it needs to be limited even further to be semantically neutral * it adds complexity to a part of the peepholer that is already a bit too complicated (the more peephole assumptions we make, the harder it is to maintain, especially when opcodes are added, deleted, or changed). * changing order of execution starts to venture into territory that we've stayed away from (on purpose). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10648> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com