How to optimised with embedded Python ?

Discussion in 'Python' started by Emmanuel, Feb 1, 2004.

  1. Emmanuel

    Emmanuel Guest

    Hi,

    I would like to use optimised python scripts ( *.pyo ), in order to gain
    space.
    But I use an embedded python. The compiler can only be run from my
    application.
    How do I set the compiler, from the C api, to create optimised files ?

    Thanks by advance,

    Emmanuel
     
    Emmanuel, Feb 1, 2004
    #1
    1. Advertising

  2. Emmanuel

    John J. Lee Guest

    Emmanuel <> writes:

    > I would like to use optimised python scripts ( *.pyo ), in order to gain
    > space.
    > But I use an embedded python. The compiler can only be run from my
    > application.
    > How do I set the compiler, from the C api, to create optimised files ?


    There's a "compileall" script in the source distribution that should
    show you how to do it.


    John
     
    John J. Lee, Feb 2, 2004
    #2
    1. Advertising

  3. Emmanuel

    Emmanuel Guest

    Actually, I found a solution :
    Just after the python initialize, I increment Py_OptimsedFlag :

    (...)
    Py_Initialize();
    Py_OptimizeFlag++;
    (...)

    Works like a charm !!

    Thanks for your help,

    Emmanuel

    "John J. Lee" a écrit :

    > Emmanuel <> writes:
    >
    > > I would like to use optimised python scripts ( *.pyo ), in order to gain
    > > space.
    > > But I use an embedded python. The compiler can only be run from my
    > > application.
    > > How do I set the compiler, from the C api, to create optimised files ?

    >
    > There's a "compileall" script in the source distribution that should
    > show you how to do it.
    >
    > John
     
    Emmanuel, Feb 2, 2004
    #3
  4. Emmanuel

    John J. Lee Guest

    Emmanuel <> writes:
    > "John J. Lee" a écrit :
    > > Emmanuel <> writes:

    [...]
    > > > How do I set the compiler, from the C api, to create optimised files ?

    > >
    > > There's a "compileall" script in the source distribution that should
    > > show you how to do it.

    [...]
    > Actually, I found a solution :
    > Just after the python initialize, I increment Py_OptimsedFlag :

    [...]

    Oh, sorry, I completely misread your question. I missed the "C API"
    bit...


    John
     
    John J. Lee, Feb 7, 2004
    #4
    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. mark | r
    Replies:
    1
    Views:
    318
    Amber
    Nov 7, 2003
  2. Kamal Advani

    Optimised String Concatenation?

    Kamal Advani, Mar 8, 2006, in forum: Java
    Replies:
    2
    Views:
    395
    Chris Uppal
    Mar 8, 2006
  3. Thuswise Webmaster
    Replies:
    0
    Views:
    829
    Thuswise Webmaster
    Jun 28, 2003
  4. wrinting an optimised code

    , May 17, 2005, in forum: C Programming
    Replies:
    11
    Views:
    576
    Kevin D. Quitt
    May 19, 2005
  5. karthikbg
    Replies:
    22
    Views:
    634
    santosh
    Dec 5, 2006
Loading...

Share This Page