redundant imports
Steve Holden
steve at holdenweb.com
Thu Mar 31 17:11:31 EST 2005
Peter Hansen wrote:
> 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
Also, beware that you ship the right .pyc files - they are
version-dependent, so shipping 2.3 binaries to a 2.4 user will actually
cause a small slow-down, since the interpreter will have to check the
.pyc's for the correct magic number before ignoring them.
regards
Steve
--
Steve Holden +1 703 861 4237 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
More information about the Python-list
mailing list