Is it possible to 'compile' a script?

solosnake solosnake at solosnake._without_this_.fsnet.co.uk
Fri Oct 4 02:57:40 EDT 2002


Greg Ewing <see_reply_address at something.invalid> wrote in message
news:3D9CF0BA.6000207 at something.invalid...
> solosnake wrote:
>
> > Hello
> >
> > Does Python offer the ability to 'compile' a script into a faster form?
>
>
> How fast does it need to be? Have you actually tried
> it and found it to be too slow for your application?
> If not, I strongly suggest that you do so before
> worrying about how to make it faster. There's a
> good chance that it will be fast enough!
>
> Note that Python already compiles scripts internally
> to a bytecode before executing them, and does most
> things that are reasonably practical to interpret
> the bytecode as quickly as possible.
>
> If it's really not fast enough, all is not lost --
> you can re-code selected parts of your algorithm in
> C and call them from Python. Selected by careful
> profiling to find out what really needs to be sped
> up, of course.
>
> --
> Greg Ewing, Computer Science Dept,
> University of Canterbury,
> Christchurch, New Zealand
> http://www.cosc.canterbury.ac.nz/~greg
>
Thanks Greg. No, I haven't done any tests yet, however it would always
concern me if if could be running faster. :)  Also, if the feature I was
asking
after was available, then that would be the correct choice to use, as
opposed to re-parsing every time I need a script executed.

This interests me in particular :
> Note that Python already compiles scripts internally
> to a bytecode before executing them, and does most
> things that are reasonably practical to interpret
> the bytecode as quickly as possible.

So *in theory* at least what I am asking after is not impossible, and at
some level is already inside Python. My suggestion to those responsible for
maintaining Python is to differentiate between calling a script which is
then parsed and compiled into bytecode and executed, and calling a function
which will parse and create the bytecode, but return a handle to that (now
faster) bytecode and allow it to be executed through this handle.

Thanks for all replies.

- solosnake









More information about the Python-list mailing list