473,379 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 2631
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim Fuehner | last post by:
Dear Newsgroup, I have a problem that is somewhat related to Alexandre Gillet's ones: "build a static python executable". I would like to make a C program scriptable. Therefor, I have included...
5
by: Rafal Kleger-Rudomin | last post by:
Hello, I'm looking for a command to reset interpreter's environment i.e. unload all modules, delete variables etc. Regards, Rafal
12
by: Anon | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all I am a beginner teaching myself python, and I am enjoying it immensely :) As a language it is great, I real treat to study, I actually...
2
by: Jarppe | last post by:
Hello, What should I do to be able to call Pyhton interpreter from a posix thread that is created in C? I have a C-library that creates a thread and then makes callbacks to user supplied...
6
by: Engineer | last post by:
I'm looking for a Python interpreter written in BASIC, preferably Visual Basic, and one written in VBA would be best of all. An alternative would be a Python-2-Basic compiler. Unfortunately I...
12
by: Rex Eastbourne | last post by:
Hi, I'm interested in running a Python interpreter in Emacs. I have Python extensions for Emacs, and my python menu lists "C-c !" as the command to run the interpreter. Yet when I run it I get...
5
by: wahn | last post by:
Hi, Here is a problem I came across and need some help with. I developed a little Python script with some classes which runs standalone and communicates with a database via sockets. So far...
6
by: neokosmos | last post by:
I was wondering what the approximate amount of memory needed to load a Python interpreter (only, no objects, no scripts, no nothing else) in a Linux 2.6 environment. According to ps, it appears to...
0
by: has | last post by:
Hi all, need a little bit of advice on dynamically binding an embedded Python interpreter. First, the code for anyone that wants a look: ...
4
by: Brad Johnson | last post by:
I have embedded a single threaded instance of the Python interpreter in my application. I have a place where I execute a Python command that calls into C++ code which then in turn calls back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.