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

Yury Selivanov yselivanov.ml at gmail.com
Fri Feb 12 15:36:20 EST 2016


On 2016-02-11 10:58 PM, Andrew Barnert via Python-ideas wrote:
> tl;dr: We should turn dis.Bytecode into a builtin mutable structure similar to byteplay.Code, to make PEP 511 bytecode transformers implementable.

Big -1 on the idea, sorry.

CPython's bytecode is the implementation detail of CPython.  PyPy has 
some opcodes that CPython doesn't have, for example.  Who knows, maybe 
in CPython 4.0 we won't have code objects at all :)

Adding something to the standard library means that it will be supported 
for years to come.  It means that the code is safe to use.  Which, in 
turn, guarantees that there will be plenty of code that depends on this 
new functionality.  At first some of that code will be bytecode 
optimizers, later someone implements LINQ-like extension, and in no time 
we lose our freedom to work with opcodes.

If this "new functionality" is something that depends on CPython's 
internals, it will only fracture the ecosystem.  PyPy, or Pyston, or 
IronPython developers will either have to support byteplay-like stuff 
(which might be impossible), or explain their users why some libraries 
don't work on their platform.

Yury



More information about the Python-ideas mailing list