3 ms·
The issue seems to be that CPython is optimizing the locals access for the exec_code_object_and_return_x by using indices into the array, instead of the normal
by revelation 15y ago
The issue seems to be that CPython is optimizing the locals access for the exec_code_object_and_return_x by using indices into the array, instead of the normal lookup by name (which, by incident, is what the compiled code uses).
If I understand http://bugs.python.org/issue4831 http://bugs.python.org/issue4831 correctly, CPython 2.7 should not be optimizing the locals access in this way with an exec statement present.