A Python Mystery
gist.github.com
gist.github.com
If I understand http://bugs.python.org/issue4831 correctly, CPython 2.7 should not be optimizing the locals access in this way with an exec statement present.
I'm in the process of blogging about this and other quirks of exec -- I'll post back here once that's up.
> x = 124236
> y = 124237
> y -= 1
> id(x)
140474467900408
> id(y)
140474467900360
> x is y
False
> x = 1
> y = 2
> y -= 1
> id(x)
140558102245816
> id(y)
140558102245816
> x is y
True
http://stackoverflow.com/questions/306313/python-is-operator...