How does python work

G

Geiregat Jonas

I'm asking myself how Python code get's executed ...
What happens first etc ...
First read the file and then ..
How python handle's variable internally ...
also could someone point me to the build in functions in the python source
code ?
 
A

A.M. Kuchling

I'm asking myself how Python code get's executed ...
What happens first etc ...
First read the file and then ..

The code is parsed and compiled into bytecode that can then be executed.
Consult a textbook on parsing or programming language implementation for
more details about how parsing is done.

I thought someone (MWH?) wrote an explanation of Python's internals once,
but can't find anything at the moment. The Python docs have some relevant
material (http://www.python.org/doc/current/ext/ext.html), but that document
doesn't concentrate on the implementation details, just on the bits you can
easily access from extensions.
also could someone point me to the build in functions in the python source
code ?

They're in Python/bltinmodule.c.

--amk
OTHELLO: Once more, well met at Cyprus!
-- _Othello_, II, i
 
P

Peter Scott

Geiregat Jonas said:
I'm asking myself how Python code get's executed ...
What happens first etc ...
First read the file and then ..
How python handle's variable internally ...
also could someone point me to the build in functions in the python source
code ?

The Python Library Reference has a section on "Built-in Functions,
Types, and Exceptions" at
<http://www.python.org/doc/current/lib/builtin.html>. There is also a
section documenting some rather low level internal modules at
<http://www.python.org/doc/current/lib/language.html>, such as parser,
which lets you access the parse tree, and dis, a disassembler for
python bytecode.

-Peter
 
M

Michael Hudson

A.M. Kuchling said:
The code is parsed and compiled into bytecode that can then be executed.
Consult a textbook on parsing or programming language implementation for
more details about how parsing is done.

I thought someone (MWH?) wrote an explanation of Python's internals once,
but can't find anything at the moment.

I've threatened to do it, but not actually done it.

If you can read C, these things aren't that hard to figure out (though
tags or cscope certainly help...).

Cheers,
M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top