[Python-ideas] Incorporating something like byteplay into the stdlib

Yury Selivanov yselivanov.ml at gmail.com
Fri Feb 12 16:57:23 EST 2016


On 2016-02-12 4:45 PM, Yury Selivanov wrote:
>> In the same way, having a mutable dis would make it easier, not 
>> harder, to change CPython without breaking bytecode processors.
>
> PEP 492 added a bunch of new opcodes.  Serhiy is exploring an 
> opportunity of adding few more LOAD_CONST_N opcodes.  How would a 
> mutable byteplay-code-like object in the dis module help that? 


The key point here is not the API of your mutable 
code-object-abstraction.  The problem is that bytecode modifiers rely on:

1. existence of certain bytecodes;
2. knowing their precise behaviour and side-effects;
3. matching/patching/analyzing exact sequences of bytecodes.

High-level abstractions won't help with the above.  Say we want to 
remove a few opcodes in favour of adding a few new ones.  If we do that, 
most of code optimizers will break.

That's why our low-level peephole optimizer is private - we can update 
it ourselves when we need it.  It's completely in our control.

Also, AFAIK, FAT Python analyzes/transforms AST.  I'm not sure how 
byteplay could help FAT Python specifically.

Yury


More information about the Python-ideas mailing list