[issue32615] Inconsistent behavior if globals is a dict subclass

STINNER Victor report at bugs.python.org
Thu Jan 16 17:18:38 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

exec() function is currently quite clear on which types are accepted or not: exact dict for globals, mapping for locals.

*  "If only globals is provided, it must be a dictionary (and not a subclass of dictionary), which will be used for both the global and the local variables."
* "If provided, locals can be any mapping object."

Moreover, the requirement on the exact dict type allowed to implement an optimization on globals in Python 3.8:

"LOAD_GLOBAL instruction now uses new “per opcode cache” mechanism. It is about 40% faster now. (Contributed by Yury Selivanov and Inada Naoki in bpo-26219.)"

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32615>
_______________________________________


More information about the Python-bugs-list mailing list