Guide to the python interp. source?

Michael Hudson mwh at python.net
Fri Jul 26 09:03:54 EDT 2002


"Tim Gahnström /Bladerman" <tim at bladerman.com> writes:

> Hi
> <<Essence of question>>
> Is there a guide or a recomended way to "get to know" the source
> code to the python interpreter?

Don't think so.  I've had thoughts of writing one, but never got far
enough into it for it to be worth showing anyone else.  It seems to be
difficult pedagogically to explain one area without requiring
knowledge of areas not yet covered.

OTOH, the interpreter source is mostly clearly layed out, well written
C.  There are dragons in some areas (bits of the import process,
coercions), but not many.

> <<Some helping background>>
> I am creating a new language and an IDE intended for beginners. This is my
> CS master thesis. I plan to use Python as primary language and the Python
> interpreter as my interpreter. I will probably need to make quite a few
> changes to the the interpreter to make the language behave the way I want,
> and I will need to monitor the state of the interperter for debugging
> purposes

Oh, and the compiler's not that nice either.  What sort of changes are
you thinking of?  You may be better off using the compiler package in
the standard library, or at least leveraging it.

> <<Some really uininteresting background>>
> Python is, I think, a verry intuitive language for beginners, with some
> modifications it can be even better. Especially with a good IDE. That is
> what I have set out to create. I have designed the language I want to creat
> and I have made the first draft of the IDE using Tkinter but I have a big
> problem with the python source. It is quite extensive and I am not one of
> those people that can have a look at a million lines of code and se the
> connections.

The Python source also has the property that you don't need to read
all of it to get the big picture.

> The best would be, ofcourse, some UML documentation 

Of course?  Um, dissent from here...

> but I would also be happy if I found a small description och what
> code is where,

Well, the interpreter mainloop is in Python/ceval.c, object type
implementations are in Object/*.c, ... 

> how to compilem,

compiling is easy, at least on Unix or Win32.

> design thoughts

Reading Include/object.h (and maybe other headers -- objimpl.h?) might
give some clues.

> or anything like that. A lot of projects have "a small guide for
> wannabe developers" but I havn't found anything like that for this
> project.

There's http://www.python.org/dev/, but there's nothing of the sort
you're asking for here, really.

> Not on the website and not in any FAQ.

> Things I want to change is for example, everything should be "call by
> refferense", 

That may be very hard.  If you want things like this:

def f(x):
    x += 1

i = 2
f(i)
i --> 3

then you have problems.

> it shall not by case sensitive,

Easy.

> redirect output,

Probably easy.  Not quite sure what you mean here.

> better errormesages, 

Examples?  Feel free to contribute these back to the project...

> etc, etc.
> 
> <<Thoughs that is of no interest to anyone that might answer my real
> question>>
> I have given it some thought and think that I can make alot of my changes by
> preprocessing the code and turn it into correct python code before I send it
> to the interpreter but that is not viable for everything so I will need to
> look into the sources anyway. For instance the graphics libary I plan to
> create I can do all in Python (speed is not an issue).
> Any thoughts on the subject is ofcourse more then welcome and I am sure I
> will come back with other questions but the first thing I need is a guide to
> the Python interpreter sources.

Have you written any Python extensions in C?  That gives you a pretty
good idea of what is going on in a certain, important area.

Cheers,
M.

-- 
  I never realized it before, but having looked that over I'm certain
  I'd rather have my eyes burned out by zombies with flaming dung
  sticks than work on a conscientious Unicode regex engine.
                                             -- Tim Peters, 3 Dec 1998



More information about the Python-list mailing list