redundant imports

Peter Hansen peter at engcorp.com
Thu Mar 31 18:12:40 CEST 2005


max(01)* wrote:
> this leads me to another question. since *.pyc files are automatically 
> created the first time an import statement in executed on a given 
> module, i guess that if i ship a program with modules for use in a 
> directory where the user has no write privileges then i must ship the 
> *.pyc files along too. right?

Not required except for performance reasons.  If the .pyc
files don't exist, the .py files are recompiled and the
resulting bytecode is simply held in memory and not cached
and the next startup will recompile all over again.

Note also that the main file (the one invoke from the
command line) is never cached in a .pyc...

-Peter



More information about the Python-list mailing list