[Python-Dev] Re: proto-pep: How to change Python's bytecode

Terry Reedy tjreedy at udel.edu
Sat Dec 25 02:54:32 CET 2004


"Brett C." <bac at ocf.berkeley.edu> wrote in message 
news:41CC7F67.9070009 at ocf.berkeley.edu...

At to the title, bytecodes are a property of the CPython implementation, 
not of Python itself.  Since I think the distinction is quite important to 
maintain, I would insert the missing 'C' and everywhere else as 
appropriate.

> After implementing over 10 new opcodes for my thesis I figured I should 
> write down the basic steps in an info PEP so that there is enough 
> guidelines with this PEP and PEP 306 to cover the bases on changes to the 
> language itself.

Over the last several years, various people have reported experimenting 
with CPython's bytecodes.  I wonder if it would be helpful to have a 
respository of the results, in one place, for new experimenters and curious 
people to peruse.

> Anyway, let me know if I seem to be missing anything or have something to 
> add.

As I said, the importanct 'C' qualifier.

> PEP: XXX
> Title: How to change Python's bytecode

/P/CP/

> Python source code is compiled down to something called bytecode.

Suggested replacements in quotes:
"CPython compiles Python source code to something called bytecode."

> This  bytecode (which can be viewed as sequences of opcodes)
> defines what Python is capable of.

This is backwards.  "The language, as defined in the Reference Manual, 
determines what bytecodes are needed (collectively, not one by one) for a 
bytecode implementation."

>  As such, knowing how to add, remove, or change the bytecode is
> important to do properly when changing the abilities of the Python 
> language.

"Therefore, changes in the language may require changes in the set of 
bytecodes.  In addition, changing the bytecode set for a given definition 
may result in desireable changes in the interpreter behavior.  This 
document describes how to do so for either reason."

> Rationale
> =========
>
> While changing Python's bytecode is not a frequent occurence, it still 
> happens.

/P/CP/   Experiments are much more frequent than committed changes -- all 
of which start as experiments.
...

Terry J. Reedy





More information about the Python-Dev mailing list