Python ByteCode and Virtual Machine documentation

Terry Reedy tjreedy at home.com
Thu Oct 25 20:51:46 EDT 2001


"Lucio Torre" <lucio at movilogic.com> wrote in message
news:mailman.1004049566.23516.python-list at python.org...
> Ive seen someone comment on the bytecode translation of some pieces
of
> code, but never seen any documentation.  So i have two questions:
>
> a) where can i find documentation of the virtual machine of python?
> (suppose i want to implement Thyton, a TCP parasitic computing
version
> of python)

Try the 'dis' (disassemble) library module

> b) is messing with the virtual machine a 'bad thing'?

For most of us, probably yes.  But for fun, search google for
'bytecodehacks' (its non-library module that enables you to hack byte
codes).

> i mean, for
> example, that the VM is not defined because thats implementation
> dependant and i should only care about understanding and parsing the
> code? if its so, why?

The VM currently used by the standard C implementation is intentially
and explicitly *not* part of the language specification.  (The Jython
implementation, for instance, compiles Python to Java byte codes
instead.)  It is an implementation device whose details can (and do)
change from release to release.  If someone were to develope a
completely different but substantially better VM, GvR would feel free
to adopt that instead.

Terry J. Reedy






More information about the Python-list mailing list