proto-pep: How to change Python's bytecode
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.
To go along with this I also plan to write some benchmarks for individual
opcodes that could possibly lead to a testing suite for the opcodes themselves
(will probably do this piece-meal and put it up on SF initially since there are
a lot of opcodes).
Anyway, let me know if I seem to be missing anything or have something to add.
After a reasonable time of non-response to this I will request a PEP number
(assuming people don't think this PEP is stupid).
------------------------------------------
PEP: XXX
Title: How to change Python's bytecode
Version: $Revision: 1.4 $
Last-Modified: $Date: 2003/09/22 04:51:50 $
Author: Brett Cannoon
Brett C. wrote:
A few things can be done to make sure that development goes smoothly when experimenting with Python's bytecode. One is to delete all .py(c|o|w) Don't you mean ".pyc or .pyo (remember such files in zips as well)" .pyw is normal python source.
-- Scott David Daniels Scott.Daniels@Acm.Org
Scott David Daniels wrote:
Brett C. wrote:
A few things can be done to make sure that development goes smoothly when experimenting with Python's bytecode. One is to delete all .py(c|o|w)
Don't you mean ".pyc or .pyo (remember such files in zips as well)" .pyw is normal python source.
Yeah, my bad. Been a while since I have written a .pyw file. -Brett
"Brett C."
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
Terry Reedy wrote:
"Brett C."
wrote in message news:41CC7F67.9070009@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.
Then the same could be said for PEP 306. But I don't mind changing the title.
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.
Wouldn't hurt. Adding that section would not be bad, but I don't have the inclination to hunt them down. What do others think about having this section? -Brett
Brett C. wrote:
Terry Reedy wrote:
"Brett C."
wrote.... 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. Wouldn't hurt. Adding that section would not be bad, but I don't have the inclination to hunt them down. What do others think about having this section? What you could do is declare a wiki page which anyone could go to; less work for you, and forms a new place to pool knowledge.
-- Scott David Daniels Scott.Daniels@Acm.Org
>> 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. Brett> Wouldn't hurt. Adding that section would not be bad, but I don't Brett> have the inclination to hunt them down. What do others think Brett> about having this section? How about just references in the PEP? I presented a paper several years ago at a Python workshop on a peephole optimizer for Python. Also, Michael Hudson has his no-longer-active bytecodehacks stuff: http://www.foretec.com/python/workshops/1998-11/proceedings/papers/montanaro... http://bytecodehacks.sourceforge.net/bch-docs/bch/index.html I imagine there's other stuff as well. Skip
OK, latest update with all suggest revisions (mention this is for CPython,
section for known previous bytecode work).
If no one has any revisions I will submit to David for official PEP acceptance
this weekend.
----------------------------------
PEP: XXX
Title: How to change CPython's bytecode
Version: $Revision: 1.4 $
Last-Modified: $Date: 2003/09/22 04:51:50 $
Author: Brett Cannoon
participants (5)
-
Brett C.
-
Brett C.
-
Scott David Daniels
-
Skip Montanaro
-
Terry Reedy