Reg Python Byte code
Steve Holden
steve at holdenweb.com
Mon Aug 22 08:04:05 EDT 2005
praba kar wrote:
> Dear All,
>
> Python 2.3 creates byte code with *.pyc
> extention. But Python 2.4 creates bytes code with
> *.pyo. Is there any difference between *.pyc
> and *.pyo?.
>
Yes. The .pyo files are optimized by removing certain features that
aren't essential to execution (things like doc strings).
> Actually After python compiled a program
> then that program will run from the *.pyc byte
> code. If I delete that byte code what will be
> happen.?
>
The next time you import the module concerned the interpreter will
recreate the .pyc file.
> If I delete *.pyc byte code in the python
> 2.3 then It will create again *.pyc byte code.
> But If I delete *.pyo byte code in the python
> 2.4 then It will not create again *.pyo. Why
> this difference.
>
There is no difference between 2.3 and 2.4 in their treatment of .pyc
and .pyo files. The .pyo files are used when you give the interpreter
the -O option to indicate you want optimized performance. Most people
happily live without ever using this option, but in certain cases it can
save some run time.
> If I delete byte code of the python.
> I want to know Whether it will affect the
> performance of the programme or not.
>
The interpreter will have to take the time to re-create the .pyc on
imported modules. If the files can't be created (due to permission
problems or whatever) the module has t be recompiled each execution.
> Kindly clear me all the doubts regarding
> byte code of python.
>
> with regards
> Prabahar
>
>
Hope this helps.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list