Python "byte code" description

Terry Reedy tjreedy at udel.edu
Sat Dec 7 02:53:51 EST 2002


"Derek Thomson" <derek at wedgetail.com> wrote in message
news:3df19e31$0$26157$afc38c87 at news.optusnet.com.au...

> To the best of my understanding, the Python interpretor executes
Python
> code that has been compiled to a Python byte code.

This is true for the CPython interpreter and only for that
interpreter.  Jython compiles to javacode.  Another (experimental)
implementation translated most of Python to another language.  The
point is that PyCode is an implementation detail of one
implementation.  It is not a part of the language itself or its
definition.  You can understand almost all of Python without knowing
about compilation for efficiency.

> Is this byte code specified anywhere? I can't seem to find anything,
> except this very cursory overview:
>
> http://python.org/doc/current/lib/bytecodes.html


Aside from the C code itself, that *is* the documentation -- just so
you can understand the output of dis module.

> Is there anything more comprehensive, apart from the Python
> implementation itself? Not only do I need the actual file format,

Why?  The internal .pyc format is an internal implementation detail
subject to change with each version.  The doc for this is the c code
which write and reads it.   It consists of a magic number, PyCode, and
marshaled versions of literals.

> but also the run time assumptions (stack and memory characteristics)
would
> also be necessary.

Python grabs what it needs as long as the OS will give it.  Specifics
depend on your OS and hardware.  It 'assumes' that the system
resources are sufficient for the task you give it.

Perhaps you can restate your question to be more specific, and give a
bit of context.

Terry J. Reedy





More information about the Python-list mailing list