473,326 Members | 2,134 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,326 software developers and data experts.

Any pointers/advice to help learn CPython source?

Anyone have any good advice to someone interested in learning about
innards of Python implementation?

e.g. What is best place to start?

Where can I get a 10,000 ft. overview of general structure?

Anyone written docs on helping do this?

How did other people successfully make it through?

Chris

May 17 '06 #1
3 1588
se******@spawar.navy.mil wrote:
Anyone have any good advice to someone interested in learning about
innards of Python implementation?

e.g. What is best place to start?

Where can I get a 10,000 ft. overview of general structure?

Anyone written docs on helping do this?

How did other people successfully make it through?


Depends on what you want to get out of it. There are only a handful of
top level directories that are interesting:

Include - include files
Objects - all Python objects (list, dict, int, float, functions, and
many others)
Python - core interpreter and other support facilities

Lib - Python stdlib (Lib/test is the test suite)
Modules - C extension modules
Parser - simple parser/tokenizer

The last three probably aren't interesting. However, if you are
interested in the GC (or SRE) implementation, then you should look
under Modules as gcmodule.c and _sre.c are there. So are a bunch of
others.

Include/ isn't particularly interesting. Objects/ isn't too
interesting either from the standpoint of learning about the
interpreter. Although the object implementations may be interesting in
their own right. Each object is in an unsurprising file named
something like: listobject.c or intobject.c.

That leaves Python/ which is where the real innards are. If you are
interested in the interpreter, then Python/ceval.c is pretty much it.
The compiler is primarly in Python/compile.c, but also see Python/ast.c
(2.5 only) and Python/symtable.c. All the global builtin functions are
in Python/bltinmodule.c. Import support is in Python/import.c. Most
of the other files in Python/ are small and/or platform specific. They
probably aren't as interesting in general.

n

May 18 '06 #2
Wow thanks for your detailed reply. Mainly I just wanted to understand
the theory and ideas needed to make an interpreter. Your directory
description helped.

Chris

May 18 '06 #3
There is also an interesting pep which describe the front-end

http://www.python.org/dev/peps/pep-0339/

It doesn't explain the whole things, but it gives few hints where to
start to read the code. BTW, the main difficulty is that there are fat
C files and you should ask yourself what do you want to learn, because
instead it can be interesting to read the compiler module or to look at
pypy source code. Obviously if your motivations are to understand some
internals of CPython you want to study CPython ! lol

--
sébastien
http://seb.dbzteam.com

May 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

75
by: Howard Nease | last post by:
Hello, everyone. I would appreciate any advice that someone could give me on my future career path. Here is my situation: I am a bright Junior in a very well-respected private high school, taking...
388
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
4
by: | last post by:
I am a recent college graduate and am looking for some advice on how to be a skilled C++ developer. My educational background is from a quite mediocre campus. Can anybody please explain what is...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
10
by: arnuld | last post by:
thanks
2
by: squishy | last post by:
I want to learn enough C++ to accomplish a couple of tasks. (1) I want to be able to understand and change open source VNC apps (like ultravnc) to suit my needs. (2) I want to be able to write...
69
by: Yee.Chuang | last post by:
When I began to learn C, My teacher told me that pointer is the most difficult part of C, it makes me afraid of it. After finishing C program class, I found that all the code I wrote in C contains...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.