Reg Python Byte code

P

praba kar

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?.

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.?

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.

If I delete byte code of the python.
I want to know Whether it will affect the
performance of the programme or not.

Kindly clear me all the doubts regarding
byte code of python.

with regards
Prabahar








____________________________________________________
Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html
 
M

Magnus Lycka

praba said:
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?.

Since way back, ordinary Python bytecode uses .pyc,
and optimized Python bytecode (python -O) uses .pyc.
This has nothing to do with Python versions. As I
recall, Python installers on the most common platforms
have pre-generated both .pyc and .pyo file for the
standard library since before 2.3.
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.?

Python will have to compile the module again, the
next time it's imported.
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.

Because you didn't use 'python -O'. It used the
..pyc version, not the .pyo. It's there too!
If I delete byte code of the python.
I want to know Whether it will affect the
performance of the programme or not.

There is little point in removing files that
will come back again. If you're allergic to
bytecode files, you can writeprotect those
dictionaries though. Each python process that
imports a module will then have to compile the
module. Whether this affects performance depends
on how you use Python. For long runinng tasks,
it will probably not matter, for e.g. big CGI
scripts, it might have severe implications.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top