Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10349

Re: Only Bytecode, No .py Files

From Christian Heimes <lists@cheimes.de>
Subject Re: Only Bytecode, No .py Files
Date 2011-07-27 00:04 +0200
References <1311693548.3796.212.camel@ewzdev.atlantic> <CAGGBd_rmMyNdqaokHF5aOtC-YS3xjjW83q1-5dQz=wF31NbNbg@mail.gmail.com> <1311715229.3796.224.camel@ewzdev.atlantic>
Newsgroups comp.lang.python
Message-ID <mailman.1512.1311717864.1164.python-list@python.org> (permalink)

Show all headers | View raw


Am 26.07.2011 23:20, schrieb Eldon Ziegler:
> That seemed like a good idea but the .py file was complied even though
> it was dated 2001-01-01 00:00:00. Python must be checking something
> beside the date.

The first four bytes of a pyc file contain the magic header. It must
match the magic of the current Python version. The next four bytes
contain the pyc_mtime. It must match the mtime of the corresponding .py
files as returned by fstat().st_mtime. If the magic doesn't match or the
mtime header doesn't match the mtime of the .py file, the pyc is ignored.

Hint: If you run python with the -v option, you can get information why
a pyc file is ignored.

$ touch test.py
$ pycompile test.py
$ python -v -c "import test"
...
# test.pyc matches test.py
import test # precompiled from test.pyc
...
$ touch test.py
$ python -v -c "import test"
...
# test.pyc has bad mtime
import test # from test.py
...

Christian

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Only Bytecode, No .py Files Christian Heimes <lists@cheimes.de> - 2011-07-27 00:04 +0200
  Re: Only Bytecode, No .py Files harrismh777 <harrismh777@charter.net> - 2011-07-26 20:32 -0500
    Re: Only Bytecode, No .py Files Christian Heimes <lists@cheimes.de> - 2011-07-27 11:27 +0200
      Re: Only Bytecode, No .py Files harrismh777 <harrismh777@charter.net> - 2011-07-27 13:45 -0500

csiph-web