Le vendredi 18 décembre 2015, Andrew Barnert via Python-Dev < python-dev@python.org> a écrit : > > >> Builtins do two dict lookups. > > > > Two? > > Actually, I guess three: first you fail to find the name in globals, then > you find __builtins__ in globals, then you find the name in __builtins__ or > __builtins__.__dict__. >
Getting builtins from globals in done when the frame object is created, and the lookup is skipped in the common case if qu recall correctly. LOAD_NAME does a lookup on function globals, if the key doesn't exist (common case for builtins), a ceond lookup is done in frame builtins. Open Python/ceval.c and see to code. There is an optimisation for fast lookup in two dict. Victor
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com