newbie IronPython compiled scripts speed question

D

dtlog

Hello, and sorry if this has been asked before...
I searched the faqs at python.org and didn't find an answer:
does using IronPython, instead of CPython, and compiling the
scripts into native windows executables (I heard IronPython
can do that) result in faster execution times? Or is it just
a matter of convenience (for use in systems without python
installed)?

So the question is, should I switch to IronPython and compile
my scripts, or learn to use something like pyinline or Psyco?
 
L

Lawrence Oluyede

dtlog said:
I searched the faqs at python.org and didn't find an answer:
does using IronPython, instead of CPython, and compiling the
scripts into native windows executables (I heard IronPython
can do that) result in faster execution times?

I don't know what you heard but IronPython generates IL code which
happens to be the bytecode of the CLR (the runtime of .NET). So you are
not generating "native" stuff but a PE executable wrapping the .NET
stuff in it. See:
http://en.wikipedia.org/wiki/Portable_Executable#.NET.2C_metadata.2C_and
_the_PE_format

It seems IronPython being faster than CPython 2.4 in some tests but I
can't say anything about that because I haven't seen that tests :)
 
B

bearophileHUGS

dtlog:
So the question is, should I switch to IronPython and compile
my scripts, or learn to use something like pyinline or Psyco?

Learning to use Psyco is very easy, for a basic usage you just have to
put in your code:
import psyco
psyco.full()

For a better usage you can do:
psyco.bind(functioname)
for just the functions that you have seen can enjoy the compilation.

For a smart usage you can learn few tricks to help its job. The last
page of the psyco manual helps.

pyinline is rather easy to use if you have linux and you know C.

Bye,
bearophile
 
D

dtlog

I don't know what you heard but IronPython generates IL code which
happens to be the bytecode of the CLR (the runtime of .NET). So you are
not generating "native" stuff but a PE executable wrapping the .NET
stuff in it.

not native... I see.
thanks for the info, so there's not much point in turning to
IronPython for speeding up scripts yet...
 
D

dtlog

Learning to use Psyco is very easy, for a basic usage you just have to
put in your code:
import psyco
psyco.full()

For a better usage you can do:
psyco.bind(functioname)
for just the functions that you have seen can enjoy the compilation.

For a smart usage you can learn few tricks to help its job. The last
page of the psyco manual helps.

pyinline is rather easy to use if you have linux and you know C.

thanks, I'll check out psyco's documentation, since unfortunately the
scripts will be run on a Windows box, and using a compiler other than
VC++ is not an option... on that note, is there a tutorial/guide on
making python (and therefore pyinline) aware of the VC++ compiler
installed on the machine so it can be used for automatic compilation?
Is a change in some configuration file, or a call of some function needed?
 
R

Ravi Teja

In most cases, carefully examine why you need native code at all. Since
a good number of performance sensitive CPython modules are in fact
written in C to begin with, the improvements may not always be
significant.

I don't know about your application but here are some general
observations. Beginers are often enamored with native code. This is
normal. Unless your application is explicitly low level, native code is
not worth bothering with.
thanks, I'll check out psyco's documentation, since unfortunately the
scripts will be run on a Windows box, and using a compiler other than
VC++ is not an option...

1.) mingw works quite well for writing Python extensions.
2.) ctypes is a great way to incorporate native code. Create a dll in
whatever native language you please and call it from Python.
3.) Since you are on just MS Windows, you can use COM to wrap your
native code.
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top