473,770 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2656
"g.franzkow iak" <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**********@o nline.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_fun c))

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
1446
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 a python interpreter into the program. Additionally I have wraped all the program's interfaces that I need, using SWIG. Finally, I have created a shared library, which includes this interface and all functions that are to be available from...
5
41286
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
2407
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 find it fun to study the language heh Anyways to the point of my post.....
2
2571
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 function from that threads context. I'm writing a wrapper for this library and I need to call python interpreter from that callback. I'm using Python 2.3 in Linux.
6
2408
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 have to develop some special purpose code in an organization where my only development environment is Microsoft Office Visual Basic for Applications. The security 'droids have decided that since the MS Office Suite is a "standard" application...
12
12284
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 the message "Spawning Child Process: invalid argument." What do I need to do/download to fix this? I read in a post in this group from a while back where someone had the following lines in his .emacs file:
5
3228
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 everything works fine. I also successfully embedded the Python interpreter into a plugin for a commercial 3D package (in this case Houdini - http://www.sidefx.com/ - using the HDK). I can use the interpreter to run Python commands and get values back...
6
5450
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 be 3312 bytes, which seems absurdly low to me. However, when I check the size of my Python executable, it looks like it is only about 5600 bytes in size, so maybe this is reasonable? Right now, I currently have one bare Python interpreter...
0
1548
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: http://trac.macosforge.org/projects/appscript/browser/py-osacomponent/trunk/PyOSA It's a Python OSA component for OS X. The idea is that you wrap up a scripting language interpreter as a Carbon Component Manager component (similar to writing a COM component); applications can then call the
4
2311
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 into Python using the same interpreter. I get a fatal error which is "PyThreadStage_Get: no current thread." I guess I understand why I can't have two invocations of the same interpreter thread in one call stack, but how would I go about solving...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.