<div dir="ltr">In a function call with named arguments the code generated doesn't follow that pattern:<div><br></div><div>dis.dis(lambda : f(a=1,b=2,c=3))</div><div><br></div><div>displays:</div><div><br></div><div><div> 1 0 LOAD_GLOBAL 0 (foo)</div><div> 3 LOAD_CONST 1 ('a')</div><div> 6 LOAD_CONST 2 (1)</div><div> 9 LOAD_CONST 3 ('b')</div><div> 12 LOAD_CONST 4 (2)</div><div> 15 LOAD_CONST 5 ('c')</div><div> 18 LOAD_CONST 6 (3)</div><div> 21 CALL_FUNCTION 768 </div><div> 24 RETURN_VALUE </div></div><div><br></div><div>so the problem is only about inlined dicts (somewhat common but not ubiquitous as they are in Javascript).</div><div><br></div><div>Andrea</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 22, 2015 at 12:57 AM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 01/21/2015 11:16 PM, Neil Girdhar wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Why not have BUILD_MAP work like BUILD_LIST? I.e., STORE_MAP takes a<br>
parameter n and adds the last n pairs of stack elements into the n-1 stack<br>
element (the dictionary).<br>
</blockquote>
<br></span>
It probably wouldn't make much difference. Building a list is<br>
substantially cheaper if you have all the items on hand and can<br>
copy them in en masse. But adding an item to a dict entails<br>
quite a lot of overhead, since you need to hash the key, look<br>
for a free slot, etc. and this would likely swamp any gain<br>
from executing less bytecodes. And on the other side of the<br>
equation, evaluating the items one at a time requires less<br>
stack space, so the stack frame can be smaller.<br>
<br>
But as always, you can't be sure without measuring it, and<br>
this would be a good thing for someone interested to try out.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Greg<br>
<br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/agriff%40tin.it" target="_blank">https://mail.python.org/<u></u>mailman/options/python-dev/<u></u>agriff%40tin.it</a><br>
</font></span></blockquote></div><br></div>