steve at holdenweb.com
Fri Dec 3 14:05:24 CET 2004
Peter Hansen wrote:
> Matt Gerrans wrote:
>> "Peter Hansen" <peter at engcorp.com> wrote:
>>> Only pure Python code can run without change on a newer interpreter.
>> Is the interpreter smart enough to rebuild a pyc (if the corresponding
>> py file is there of course) file that was built by a previous version?
> Yes. The .pyc files contain a magic cookie that is
> different in each major version, so 2.4 will recompile
> your 2.3 .pyc files. .pyc files are not portable
> between versions, generally, excepting maintenance releases.
In fact this hidden recompilation, when it has to be applied to large
libraries, can impact performance considerably. I first came across this
when testing an application (which had its own, quite significant,
libraries) for compatibility between Cygwin and the standard Windows
interpreter, across different version numbers.
It was only when I started to look at file creation times I twigged that
running the program (for the first time only) under a different regime
was causing the libraries to be recompiled. Then the reason for the
inconsistency in run times was then obvious.
Holden Web LLC +1 800 494 3119
More information about the Python-list