[Python-Dev] Unexpected bytecode difference

Guido van Rossum guido at python.org
Fri Jan 19 19:01:38 EST 2018


Presumably because Python 3 switched to wordcode. Applying dis.dis() to
these code objects results in the same output.

>>> dis.dis(c)
          0 LOAD_NAME           0 (0)
          3 RETURN_VALUE


On Fri, Jan 19, 2018 at 3:46 PM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

> I have encountered the following difference between Python 3 and 2:
>
> (py3)
> >>> compile('xxx', '<>', 'eval').co_code
> b'e\x00S\x00'
>
> (py2)
> >>> compile('xxx', '<>', 'eval').co_code
> 'e\x00\x00S'
>
> Note that 'S' (the code for RETURN_VALUE) and a zero byte are swapped
> in Python 2 compared to Python 3.  Is this change documented
> somewhere?
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180119/0e47f7f7/attachment.html>


More information about the Python-Dev mailing list