Python interpreter in python?

arcege at shore.net arcege at shore.net
Fri Dec 22 20:56:52 CET 2000


Chui Tey <teyc at bigfoot.com> wrote:
: Is there a python implementation of the python VM? Basically for
: experimenting?

I would start first by looking at the code module, it is a full Python
interpreter written in Python.  If I remember correctly, there was talk
a while ago that Python 2 (P3K?) would have a Python-coded interpreter
instead of C based.  Guido wrote the Idle interactive shell with this
module (c.f. Tools/idle/PyShell.py).

If you still want to look into emulating the VM, then first look into
the parser modules and how it builds the VM instructions (the "Python
Language Services" in the Library Reference manual).  From there, you
can more easily handle the byte-codes and interpret data.  I would
especially look at section 17.1.6.1 "Emulation of compile()" (while not
a large section, it gives you pointers on where to go).  Then from
there, look at writing eval/exec in Python.

  -Arcege




More information about the Python-list mailing list