This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, serprex
Date 2010-12-08.04:02:47
SpamBayes Score 0.00028319506
Marked as misclassified No
Message-id <1291780969.45.0.232301475742.issue10648@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2010-12-08 04:02:49rhettingersetrecipients: + rhettinger, serprex
2010-12-08 04:02:49rhettingersetmessageid: <1291780969.45.0.232301475742.issue10648@psf.upfronthosting.co.za>
2010-12-08 04:02:47rhettingerlinkissue10648 messages
2010-12-08 04:02:47rhettingercreate