Le vendredi 18 décembre 2015, Andrew Barnert via Python-Dev <<a href="mailto:python-dev@python.org">python-dev@python.org</a>> a écrit :<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>> Builtins do two dict lookups.<br>
><br>
> Two?<br>
<br>
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__.<br>
</blockquote><div><br></div><div>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.</div><div><br></div><div>Victor </div>