[Tutor] IDLE Caching

Alan Gauld alan.gauld at freenet.co.uk
Tue Jul 25 05:51:52 CEST 2006


> So from the answers, i want to imagine how python exercise the code
> when you push the button execute. My guess before looking at the 
> docs
> or other material,
>
> 1. check python syntax
> 2. transform to byte code.
> 3. execute the byte code.

What you have is correct for a main program.
If its a module being imported there is a slight difference:

0) check if module already loaded, if yes stop
1) check if a pre-compiled version already exists
2) check if the source file is newer
3) if newer compile code to byte code and save pyc file
4) import byte code

This is described in more detail in the documentation.

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list