Comprehension with two variables - explanation needed

Chris Angelico rosuav at gmail.com
Mon Nov 24 05:51:33 CET 2014


On Mon, Nov 24, 2014 at 3:42 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Today dis() returns the above, tomorrow it may return:
>
>               0 LOAD_GLOBAL              0 (x)
>               3 INCREMENT
>               5 RETURN_VALUE
>
> (say), and the Python code remains the same even though the byte code is
> different.

I hope not! The x in the original function was a local, not a global,
and if dis.dis() says LOAD_GLOBAL for something that's not global, it
would be *very* confusing! :)

But yes, CPython could grow an INCREMENT bytecode, and it'd not break anything.

ChrisA



More information about the Python-list mailing list