targeting the PVM
Terry Reedy
tjreedy at udel.edu
Mon Oct 13 16:14:40 EDT 2003
<andy at post.tau.ac.il> wrote in message
news:mailman.60.1066060369.2192.python-list at python.org...
> I wan't to write a small compiler for a small language with some
experimental
> features. I want the target to be portable. I'm evaluating both JVM
and Python
> Virtual Machine, both of which seem to be appropriate.
Since it is a somewhat 'private' implementation device for CPython,
the developers retain the right to change the byte code or even
switch, for instance, to a register rather than stack machine.
However, the Python license will allow you to distribute any
particular interpreter (PVM) version for as long as you want.
> However I was not able to find some good documentation on "Python's
machine
> language".
Lib Reg 18.10 dis -- Disassembler for Python byte code
Lib Ref 18.10.1 Python Byte Code Instructions
To learn acual usage, experiment with dis.dis and defed functions or
compile()ed code objects. Example:
>>> import dis
>>> def bd(code): return dis.dis(compile(code,'<S>', 'eval'))
...
>>> bd('1+2')
0 SET_LINENO 0
3 LOAD_CONST 0 (1)
6 LOAD_CONST 1 (2)
9 BINARY_ADD
10 RETURN_VALUE
More information about the Python-list
mailing list