<div dir="ltr"><br><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Hi All,</span><div><font face="Arial, Helvetica, sans-serif"><br></font></div><div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">Occasionally I find myself wanting to unpack the values of a dictionary into local variables of a function.  This most often occurs when marshalling values to/from some serialization format.<br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">For example:</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,136)">def</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> do_stuff_from_json</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">json_dict</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">):</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>    actual_dict </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> json</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">loads</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><font color="#000000" style="margin:0px;padding:0px;border:0px">json_dict</font><font color="#666600" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br></span></font><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">    foo </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><font color="#000000" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px"> actual_dict</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'foo'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">]</span><span style="margin:0px;padding:0px;border:0px"><br>    bar </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px"> actual_dict</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'bar'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">]</span><span style="margin:0px;padding:0px;border:0px"><br>    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Do stuff with foo and bar.</span><span style="margin:0px;padding:0px;border:0px"><br></span></font><font color="#666600" style="margin:0px;padding:0px;border:0px"></font></div></code></div><br>In the same spirit as allowing argument unpacking into tuples or lists, what I'd really like to be able write is something like:</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,136)">def</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> do_stuff_from_json</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">json_dict</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">):</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Assigns variables in the **values** of the lefthand side by doing lookups</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># of the corresponding keys in the result of the righthand side expression.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'foo'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> foo</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'bar'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> bar</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">}</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><font color="#000000" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px"> json</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">.</span><span style="margin:0px;padding:0px;border:0px">loads</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><span style="margin:0px;padding:0px;border:0px">json_dict</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">)</span></font><font color="#000000" style="margin:0px;padding:0px;border:0px"></font></div></code></div><br><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">Nearly all the arguments in favor of tuple/list unpacking also apply to this construct.  In particular:</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">1. It makes the code more self-documenting, in that the left side of the expression looks more like the expected output of the right side.</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">2. The construct can be implemented more efficiently by the interpreter by using a dictionary analog of the UNPACK_SEQUENCE opcode (e.g. UNPACK_MAP).</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">An interesting question that falls out of this idea is whether/how we should handle nested structures. I'd expect the rule to be that something like:<br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'toplevel'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'key1'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> key1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'key2'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> key2</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">}}</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> value</span></div></code></div><br>would desugar into something equivalent to:</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">TEMP </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> value</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'toplevel'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">]</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>key1 </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> TEMP</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'key1'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">]</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>key2 </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><font color="#666600" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">TEMP</span><span style="margin:0px;padding:0px;border:0px">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'key2'</span><span style="margin:0px;padding:0px;border:0px">]</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br></span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,136)">del</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> TEMP</span></font></div></code></div><br>while something like</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><font color="#660066" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'toplevel'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">x</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> y</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">)}</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> value<br></span></font></div></code></div><div style="margin:0px;padding:0px;border:0px"><br></div>would desugar into something like:</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">x</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> y</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> value</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">[</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'toplevel'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">]</span><font color="#000000" style="margin:0px;padding:0px;border:0px"></font></div></code></div><div style="margin:0px;padding:0px;border:0px"><br></div><div style="margin:0px;padding:0px;border:0px">At the bytecode level, I'd expect this to be implemented with a new instruction, analogous to the current UNPACK_SEQUENCE, which would pop N keys and a map from the stack, and push map[key] onto the stack for each popped key.  We'd then recurse through the values left on the stack, storing them as we would store the sub-lvalues if they were in a standard assignment.  Thus the code for something like:</div><div style="margin:0px;padding:0px;border:0px"><br></div><div style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'name'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> name</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'tuple'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">(</span><font color="#000000" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px">x</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">,</span><span style="margin:0px;padding:0px;border:0px"> y</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">),</span><span style="margin:0px;padding:0px;border:0px"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'dict'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">{</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'subkey'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">:</span><span style="margin:0px;padding:0px;border:0px"> subvalue</span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">}}</span><span style="margin:0px;padding:0px;border:0px"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(102,102,0)">=</span><span style="margin:0px;padding:0px;border:0px"> values</span></font><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br></span></div></code></div><br></div><div style="margin:0px;padding:0px;border:0px">would translate into the following "pseudo-bytecode":</div><div style="margin:0px;padding:0px;border:0px"><br></div><div style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code style="margin:0px;padding:0px;border:0px"><div style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">LOAD_NAME </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'values'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">  </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Push rvalue onto the stack.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>LOAD_CONST </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'dict'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Push top-level keys onto the stack.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>LOAD_CONST </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'tuple'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>LOAD_CONST </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'name'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>UNPACK_MAP </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,102,102)">3</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">        </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Unpack keys. Pops values and all keys from the stack.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><font color="#006666" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS  = values['name']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br></span></font><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS1 = values['tuple']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS2 = values['dict']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br><br>STORE_FAST name     </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Terminal names are simply stored.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br><br>UNPACK_SEQUENCE </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,102,102)">2</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># Push the two entries in values['tuple'] onto the stack.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS  = values['tuple'][0]</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS1 = values['tuple'][1]</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS2 = values['dict']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>STORE_FAST x<br>STORE</span><font color="#666600" style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">_FAST y<br><br>LOAD_CONST </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,136,0)">'subkey'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS  = 'subkey'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>                    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS1 = values['dict']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br><br>UNPACK_MAP </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,102,102)">1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">        </span><span style="margin:0px;padding:0px;border:0px;color:rgb(136,0,0)"># TOS = values['dict']['subkey']</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br>STORE_FAST subvalue</span></font><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><br></span><font color="#008800" style="margin:0px;padding:0px;border:0px"></font></div></code></div></div><div style="margin:0px;padding:0px;border:0px"><br></div></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">I'd be curious to hear others' thoughts on whether this seems like a reasonable idea.  One open question is whether non-literals should be allowed as keys in dictionaries (the above still works as expected if the keys are allowed to be names or expressions; the LOAD_CONSTs would turn into whatever expression or LOAD_* is necessary to put the necessary value on the stack). Another question is if/how we should handle extra keys in right-hand side of the assignment (my guess is that we shouldn't do anything special with that case).</div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">-Scott</div></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></div><div style="margin:0px;padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px">P.S. <span style="font-size:small">I attempted to post this last night, but it seems to have not gone through.  Apologies for the double post if I'm mistaken about that.</span></div></div>