469,913 Members | 2,022 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

python interpreter

Hi everybody,

my interest is for the internals of the Python interpreter.

I've used up to now FORTH for something and this indirect interpreter is
very smart.
--- ASM ---------------------------------------------------------------

NEXT: LODSW ; WA <- [IP]
; IP <- IP+2
MOV T,WA ; T <- WA1 (CFA)
JMP [T] ; JMP [CFA]

--- C -----------------------------------------------------------------

for (;;)
{
w = *ip++;
(**w) ();
}

-------------------------------------------------------------------------

Where can I find informations like this for Python ?

gerd
Oct 11 '05 #1
3 2339
"g.franzkowiak" <g.***********@onlinehome.de> writes:
Where can I find informations like this for Python ?


"Use the force, read the source". Python's interpreter is more like a
big switch statement on bytecodes, though.
Oct 11 '05 #2
In <di**********@online.de>, g.franzkowiak wrote:
my interest is for the internals of the Python interpreter.

I've used up to now FORTH for something and this indirect interpreter is
very smart.
--- ASM ---------------------------------------------------------------

NEXT: LODSW ; WA <- [IP]
; IP <- IP+2
MOV T,WA ; T <- WA1 (CFA)
JMP [T] ; JMP [CFA]

--- C -----------------------------------------------------------------

for (;;)
{
w = *ip++;
(**w) ();
}

-------------------------------------------------------------------------

Where can I find informations like this for Python ?


I don't really grok the assembler code. The C code seems to assume that
there is an infinitive number of function pointers stored at `*ip`!?

The Python equivalent might be ::

for w in ip:
w()

if `ip` is a (finite) sequence of functions or callables in general.

Ciao,
Marc 'BlackJack' Rintsch
Oct 13 '05 #3
g.franzkowiak wrote:
Hi everybody,

my interest is for the internals of the Python interpreter.

I've used up to now FORTH for something and this indirect interpreter is
very smart.
--- ASM ---------------------------------------------------------------

Where can I find informations like this for Python ?


Depends on what you want. If you want to see the disassembled bytes
similar to what I cut out, see the dis module. (e.g.,
dis.dis(foo_func))

If you want to know how the byte codes are created, it's mostly in
Python/compile.c. If you want to know how the byte codes are executed,
it's mostly in Python/ceval.c.

All base Python objects implemented in C are under Objects/. All
standard modules implemented in C are under Modules/.

Get the source and build it. It's quite readable.

n

Oct 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Rafal Kleger-Rudomin | last post: by
12 posts views Thread by Anon | last post: by
12 posts views Thread by Rex Eastbourne | last post: by
5 posts views Thread by wahn | last post: by
6 posts views Thread by neokosmos | last post: by
4 posts views Thread by Brad Johnson | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.