Re: [Python-Dev] Unexpected bytecode difference

2018-01-22 Thread Alexander Belopolsky
On Fri, Jan 19, 2018 at 7:18 PM, Victor Stinner wrote: > It seems like the EXTENDED_ARG doc wasn't updated. I've opened to update the dis module documentation. I have also found a patch (mkfu4.patch) attached to issue 27095 where EXTENDED_ARG is described as

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Joe Jevnik via Python-Dev
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. On Fri, Jan 19, 2018 at 6:54 PM, Victor Stinner wrote: > Python b

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Victor Stinner
It seems like the EXTENDED_ARG doc wasn't updated. Victor 2018-01-20 1:07 GMT+01:00 Alexander Belopolsky : > On Fri, Jan 19, 2018 at 7:01 PM, Guido van Rossum wrote: >> Presumably because Python 3 switched to wordcode. Applying dis.dis() to >> these code objects results in the same output. >> >>

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Alexander Belopolsky
On Fri, Jan 19, 2018 at 7:01 PM, Guido van Rossum wrote: > 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 I expected these changes to be d

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Guido van Rossum
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.belopol...@gmail.com> wrote: > I

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Victor Stinner
Python bytecode format changed deeply in Python 3.6. It now uses regular units of 2 bytes, instead of 1 or 3 bytes depending if the instruction has an argument. See for example https://bugs.python.org/issue26647 "wordcode". But CALL_FUNCTION bytecode also evolved. Victor 2018-01-20 0:46 GMT+01:

[Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Alexander Belopolsky
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