Reg Python Byte code

Discussion in 'Python' started by praba kar, Aug 22, 2005.

  1. praba kar

    praba kar Guest

    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
    praba kar, Aug 22, 2005
    #1
    1. Advertising

  2. praba kar

    Magnus Lycka Guest

    praba kar wrote:
    > 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.
    Magnus Lycka, Aug 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas
    Replies:
    1
    Views:
    829
    Jonathan Bromley
    May 4, 2004
  2. Bharat Bhushan

    Appending byte[] to another byte[] array

    Bharat Bhushan, Aug 5, 2003, in forum: Java
    Replies:
    15
    Views:
    40,204
    Roedy Green
    Aug 5, 2003
  3. Jean-Daniel Gamache
    Replies:
    0
    Views:
    409
    Jean-Daniel Gamache
    Jul 14, 2004
  4. Peter
    Replies:
    3
    Views:
    714
    Michael Borgwardt
    Aug 5, 2004
  5. gelonida
    Replies:
    1
    Views:
    732
    Gabriel Genellina
    May 6, 2010
Loading...

Share This Page