<div dir="ltr">As a general rule, you should not expect the bytecode to be the same between different versions of CPython, including minor version changes. For example, the instructions for dictionary literals are different in 3.4, 3.5, and 3.6.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 19, 2018 at 6:54 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Python bytecode format changed deeply in Python 3.6. It now uses<br>
regular units of 2 bytes, instead of 1 or 3 bytes depending if the<br>
instruction has an argument.<br>
<br>
See for example <a href="https://bugs.python.org/issue26647" rel="noreferrer" target="_blank">https://bugs.python.org/<wbr>issue26647</a> "wordcode".<br>
<br>
But CALL_FUNCTION bytecode also evolved.<br>
<br>
Victor<br>
<span class=""><br>
2018-01-20 0:46 GMT+01:00 Alexander Belopolsky <<a href="mailto:alexander.belopolsky@gmail.com">alexander.belopolsky@gmail.<wbr>com</a>>:<br>
> I have encountered the following difference between Python 3 and 2:<br>
><br>
> (py3)<br>
>>>> compile('xxx', '<>', 'eval').co_code<br>
> b'e\x00S\x00'<br>
><br>
> (py2)<br>
>>>> compile('xxx', '<>', 'eval').co_code<br>
> 'e\x00\x00S'<br>
><br>
> Note that 'S' (the code for RETURN_VALUE) and a zero byte are swapped<br>
> in Python 2 compared to Python 3.  Is this change documented<br>
> somewhere?<br>
> ______________________________<wbr>_________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
</span>> Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>victor.stinner%40gmail.com</a><br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/joe%40quantopian.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>joe%40quantopian.com</a><br>
</div></div></blockquote></div><br></div>