Is it possible to 'compile' a script?

Steve Holden sholden at holdenweb.com
Fri Oct 4 08:41:17 EDT 2002


"Ian Holmes" <ianholmes01 at lycos.com> wrote ...
[...]
>
> When you first run a script in python the text file you created gets
> "compiled" into bytecode and run (as you mentioned) you will have also
> noticed that a .pyc file is created which is the bytecode version of
> your script.
>
> If you run myscript.py python will run myfile.pyc if it exists hence
> speeding up subsequent executions by not having to recompile into
> bytecode.  If the .py file changes then obvoiusly it is recompiled.
>

[...]
One minor glitch:  ^run^import^. Beginners are often left wondering why they
don't get .pyc files for the scripts they run, and don't realise that this
is intentional behavior on the interpreter's part.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list