How is Python designed?
Terry Reedy
tjreedy at udel.edu
Fri Dec 3 12:52:38 EST 2004
"Limin Fu" <fulimin_yuan at yahoo.com> wrote in message
news:20041203094617.9778.qmail at web80907.mail.scd.yahoo.com...
> To clarify, I mean the internal structure and design
> of python interpreter. Any hint? Thanks.
Ah... The interpreters (plural) are a separate issue from the language
itself (a Python program is a list of Python statements, etc). We'll
presume that you specifically mean the CPython interpreter, as opposed to
Jython, Viper, Ironman, PyPy, Parrot, or the human brain. For CPython:
human or other source code generator ==> Python source code
CPython compile phase:
lexer ==> tokens
parser ==> ast tree
byte code generator ==> byte codes for Python virtual machine
(see the Lib Ref chapter on the dis module for VM commands)
CPython runtime phase:
code evaluator ==> computations
(see source file ceval.c for the link between byte codes and C
functions)
CPython is currently both the reference implementation and the most
commonly used implementation. Both facts could change in the future,
possibly even with divergence between the two roles. Since Python is meant
to be a practical computer language as well as an abstract algorithm
language (for humans), a reference implementation is needed to show that
proposed language features can be sensibly implemented.
Terry J. Reedy
More information about the Python-list
mailing list